4 * Hewlett-Packard Company
6 * Permission to use, copy, modify, distribute and sell this software
7 * and its documentation for any purpose is hereby granted without fee,
8 * provided that the above copyright notice appear in all copies and
9 * that both that copyright notice and this permission notice appear
10 * in supporting documentation. Hewlett-Packard Company makes no
11 * representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
15 * Silicon Graphics Computer Systems, Inc.
17 * Permission to use, copy, modify, distribute and sell this software
18 * and its documentation for any purpose is hereby granted without fee,
19 * provided that the above copyright notice appear in all copies and
20 * that both that copyright notice and this permission notice appear
21 * in supporting documentation. Silicon Graphics makes no
22 * representations about the suitability of this software for any
23 * purpose. It is provided "as is" without express or implied warranty.
26 /* NOTE: This is an internal header file, included by other STL headers.
27 * You should not attempt to use it directly.
30 #ifndef _STLP_INTERNAL_HEAP_H
31 #define _STLP_INTERNAL_HEAP_H
35 // Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap.
37 template <class _RandomAccessIterator
>
39 push_heap(_RandomAccessIterator __first
, _RandomAccessIterator __last
);
42 template <class _RandomAccessIterator
, class _Compare
>
44 push_heap(_RandomAccessIterator __first
, _RandomAccessIterator __last
,
47 template <class _RandomAccessIterator
, class _Distance
, class _Tp
>
49 __adjust_heap(_RandomAccessIterator __first
, _Distance __holeIndex
,
50 _Distance __len
, _Tp __val
);
52 template <class _RandomAccessIterator
, class _Tp
, class _Distance
>
54 __pop_heap(_RandomAccessIterator __first
, _RandomAccessIterator __last
,
55 _RandomAccessIterator __result
, _Tp __val
, _Distance
*)
58 __adjust_heap(__first
, _Distance(0), _Distance(__last
- __first
), __val
);
61 template <class _RandomAccessIterator
>
62 void pop_heap(_RandomAccessIterator __first
,
63 _RandomAccessIterator __last
);
65 template <class _RandomAccessIterator
, class _Distance
,
66 class _Tp
, class _Compare
>
68 __adjust_heap(_RandomAccessIterator __first
, _Distance __holeIndex
,
69 _Distance __len
, _Tp __val
, _Compare __comp
);
71 template <class _RandomAccessIterator
, class _Tp
, class _Compare
,
74 __pop_heap(_RandomAccessIterator __first
, _RandomAccessIterator __last
,
75 _RandomAccessIterator __result
, _Tp __val
, _Compare __comp
,
79 __adjust_heap(__first
, _Distance(0), _Distance(__last
- __first
),
83 template <class _RandomAccessIterator
, class _Compare
>
85 pop_heap(_RandomAccessIterator __first
,
86 _RandomAccessIterator __last
, _Compare __comp
);
88 template <class _RandomAccessIterator
>
90 make_heap(_RandomAccessIterator __first
, _RandomAccessIterator __last
);
92 template <class _RandomAccessIterator
, class _Compare
>
94 make_heap(_RandomAccessIterator __first
,
95 _RandomAccessIterator __last
, _Compare __comp
);
97 template <class _RandomAccessIterator
>
99 void sort_heap(_RandomAccessIterator __first
, _RandomAccessIterator __last
)
101 while (__last
- __first
> 1)
102 pop_heap(__first
, __last
--);
105 template <class _RandomAccessIterator
, class _Compare
>
108 sort_heap(_RandomAccessIterator __first
,
109 _RandomAccessIterator __last
, _Compare __comp
)
111 while (__last
- __first
> 1)
112 pop_heap(__first
, __last
--, __comp
);
117 # if !defined (_STLP_LINK_TIME_INSTANTIATION)
118 # include <stl/_heap.c>
121 #endif /* _STLP_INTERNAL_HEAP_H */