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
00026 #ifndef load_binary_tree_from_forward_iterator_h
00027 #define load_binary_tree_from_forward_iterator_h
00028
00043 template< class pnt, class mp, typename to_map_element>
00044 void breadth_first_load_binary_tree_from_forward_iterator( pnt begin, pnt end, mp& container, to_map_element tme)
00045 {
00046 unsigned long long len = 0;
00047
00048 pnt pdata = begin;
00049 for (; pdata != end; ++len, ++pdata)
00050 {
00051 }
00052
00053 pnt *pointer_array = new pnt[len];
00054 unsigned long long i, j;
00055 for (i=0, pdata=begin; i<len; ++i, ++pdata) {
00056 pointer_array[i] = pdata;
00057 }
00058
00059 if (!container.empty()) {
00060 container.clear();
00061 }
00062
00063 unsigned long long step_size = len;
00064 j = len;
00065 while(step_size > 0) {
00066 for (i = step_size >> 1; i < len; i += step_size) {
00067 if (pointer_array[i] != end) {
00068 container.insert( tme( *pointer_array[i]));
00069 pointer_array[i] = end;
00070 }
00071 }
00072 step_size >>= 1;
00073 }
00074
00075 delete[] pointer_array;
00076 }
00077
00078 #endif