00001
00002 #ifndef _INSTIGATE_STL_INTERNAL_HEADER_IN_ALGORITHM
00003 #error This is an internal header file used to implement Instigate STL.\
00004 It should never be included directly by a program.
00005 #endif
00006
00007 #ifndef INSTIGATE_STL_SORT_HEAP_HPP
00008 #define INSTIGATE_STL_SORT_HEAP_HPP
00009
00059
00060 #include "concept.hpp"
00061 #include "_basis.hpp"
00062
00063
00064
00065
00066
00067
00068 namespace instigate {
00069 namespace stl {
00070 template <typename I>
00071 void sort_heap(I, I);
00072 template <typename I, typename C>
00073 void sort_heap(I, I, C);
00074 }
00075 }
00076
00100 template <typename I>
00101 void instigate::stl::sort_heap(I b, I e)
00102 {
00103 CHECK(instigate::stl::random_access_iterator::requirements<I>);
00104 CHECK(instigate::stl::lvalue_iterator::requirements<I>);
00105 CHECK(instigate::generic::less_than_comparable::requirements<typename
00106 stl::readable_iterator::interface<I>::value_type>);
00107 typename stl::single_pass_iterator::interface<I>::difference_type a = 1;
00108 while (a < stl::distance(b, e)) {
00109 stl::pop_heap(b, e);
00110 decrement(e);
00111 }
00112 }
00113
00139 template <typename I, typename C>
00140 void instigate::stl::sort_heap(I b, I e, C c)
00141 {
00142 CHECK(stl::random_access_iterator::requirements<I>);
00143 CHECK(stl::lvalue_iterator::requirements<I>);
00144 CHECK(stl::binary_predicate::requirements<C>);
00145 typename stl::single_pass_iterator::interface<I>::difference_type a = 1;
00146 while (a < stl::distance(b, e)) {
00147 stl::pop_heap(b, e, c);
00148 decrement(e);
00149 }
00150 }
00151
00152
00153
00154 #endif // INSTIGATE_STL_SORT_HEAP_HPP