00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef load_binary_tree_from_random_access_iterator_h
00026 #define load_binary_tree_from_random_access_iterator_h
00027
00051 template< class pnt, class mp, typename to_map_element>
00052 void breadth_first_load_binary_tree_from_random_access_iterator( pnt begin, pnt end, mp& container, to_map_element tme)
00053 {
00054 unsigned long long len = end - begin;
00055 pnt *pointer_array = new pnt[len];
00056 unsigned long long i, j;
00057 for (i=0; i<len; ++i) {
00058 pointer_array[i] = begin + i;
00059 }
00060
00061 if (!container.empty()) {
00062 container.clear();
00063 }
00064
00065 unsigned long long step_size = len;
00066 j = len;
00067 while(step_size > 0) {
00068 for (i = step_size >> 1; i < len; i += step_size) {
00069 if (pointer_array[i] != end) {
00070 container.insert( tme( *pointer_array[i]));
00071 pointer_array[i] = end;
00072 }
00073 }
00074 step_size >>= 1;
00075 }
00076
00077 delete[] pointer_array;
00078 }
00079
00080 #endif