
Go to the source code of this file.
Functions | |
| template<class pnt , class mp , typename to_map_element > | |
| void | breadth_first_load_binary_tree_from_random_access_iterator (pnt begin, pnt end, mp &container, to_map_element tme) |
| This function populates "container" by repeatedly inserting the median values. | |
Definition in file load_binary_tree_from_random_access_iterator.h.
| void breadth_first_load_binary_tree_from_random_access_iterator | ( | pnt | begin, | |
| pnt | end, | |||
| mp & | container, | |||
| to_map_element | tme | |||
| ) | [inline] |
This function populates "container" by repeatedly inserting the median values.
| begin | the first iterator in the range to be inserted | |
| end | an iterator marking the end of the range, ie. one past the last element | |
| container | the binary tree container | |
| to_map_element | a function of functor which takes an element of class *pnt, and returns a value of type std::pair<T,*pnt> create_map_pair, where T is the class of the key in container |
Definition at line 52 of file load_binary_tree_from_random_access_iterator.h.
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 }
1.5.8