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
00027
00028
00029
00030 #ifndef _STLP_INTERNAL_HEAP_H
00031 #define _STLP_INTERNAL_HEAP_H
00032
00033 #ifndef _STLP_CONFIG_H
00034 #include <stl/_config.h>
00035 #endif
00036
00037 _STLP_BEGIN_NAMESPACE
00038
00039
00040
00041 template <class _RandomAccessIterator>
00042 void
00043 push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last);
00044
00045
00046 template <class _RandomAccessIterator, class _Compare>
00047 void
00048 push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
00049 _Compare __comp);
00050
00051 template <class _RandomAccessIterator, class _Distance, class _Tp>
00052 void
00053 __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
00054 _Distance __len, _Tp __value);
00055
00056 template <class _RandomAccessIterator, class _Tp, class _Distance>
00057 inline void
00058 __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
00059 _RandomAccessIterator __result, _Tp __value, _Distance*)
00060 {
00061 *__result = *__first;
00062 __adjust_heap(__first, _Distance(0), _Distance(__last - __first), __value);
00063 }
00064
00065 template <class _RandomAccessIterator>
00066 void pop_heap(_RandomAccessIterator __first,
00067 _RandomAccessIterator __last);
00068
00069 template <class _RandomAccessIterator, class _Distance,
00070 class _Tp, class _Compare>
00071 void
00072 __adjust_heap(_RandomAccessIterator __first, _Distance __holeIndex,
00073 _Distance __len, _Tp __value, _Compare __comp);
00074
00075 template <class _RandomAccessIterator, class _Tp, class _Compare,
00076 class _Distance>
00077 inline void
00078 __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last,
00079 _RandomAccessIterator __result, _Tp __value, _Compare __comp,
00080 _Distance*)
00081 {
00082 *__result = *__first;
00083 __adjust_heap(__first, _Distance(0), _Distance(__last - __first),
00084 __value, __comp);
00085 }
00086
00087 template <class _RandomAccessIterator, class _Compare>
00088 void
00089 pop_heap(_RandomAccessIterator __first,
00090 _RandomAccessIterator __last, _Compare __comp);
00091
00092 template <class _RandomAccessIterator>
00093 void
00094 make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last);
00095
00096 template <class _RandomAccessIterator, class _Compare>
00097 void
00098 make_heap(_RandomAccessIterator __first,
00099 _RandomAccessIterator __last, _Compare __comp);
00100
00101 template <class _RandomAccessIterator>
00102 _STLP_INLINE_LOOP
00103 void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
00104 {
00105 while (__last - __first > 1)
00106 pop_heap(__first, __last--);
00107 }
00108
00109 template <class _RandomAccessIterator, class _Compare>
00110 _STLP_INLINE_LOOP
00111 void
00112 sort_heap(_RandomAccessIterator __first,
00113 _RandomAccessIterator __last, _Compare __comp)
00114 {
00115 while (__last - __first > 1)
00116 pop_heap(__first, __last--, __comp);
00117 }
00118
00119 _STLP_END_NAMESPACE
00120
00121 # if !defined (_STLP_LINK_TIME_INSTANTIATION)
00122 # include <stl/_heap.c>
00123 # endif
00124
00125 #endif
00126
00127
00128
00129