annotate DEPENDENCIES/generic/include/boost/range/algorithm/heap_algorithm.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Copyright Neil Groves 2009. Use, modification and
Chris@16 2 // distribution is subject to the Boost Software License, Version
Chris@16 3 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 4 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 5 //
Chris@16 6 //
Chris@16 7 // For more information, see http://www.boost.org/libs/range/
Chris@16 8 //
Chris@16 9 #ifndef BOOST_RANGE_ALGORITHM_HEAP_ALGORITHM_HPP_INCLUDED
Chris@16 10 #define BOOST_RANGE_ALGORITHM_HEAP_ALGORITHM_HPP_INCLUDED
Chris@16 11
Chris@16 12 #include <boost/concept_check.hpp>
Chris@16 13 #include <boost/range/begin.hpp>
Chris@16 14 #include <boost/range/end.hpp>
Chris@16 15 #include <boost/range/concepts.hpp>
Chris@16 16 #include <algorithm>
Chris@16 17
Chris@16 18 namespace boost
Chris@16 19 {
Chris@16 20 namespace range
Chris@16 21 {
Chris@16 22
Chris@16 23 /// \brief template function push_heap
Chris@16 24 ///
Chris@16 25 /// range-based version of the push_heap std algorithm
Chris@16 26 ///
Chris@16 27 /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
Chris@16 28 /// \pre Compare is a model of the BinaryPredicateConcept
Chris@16 29 template<class RandomAccessRange>
Chris@16 30 inline RandomAccessRange& push_heap(RandomAccessRange& rng)
Chris@16 31 {
Chris@16 32 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
Chris@16 33 std::push_heap(boost::begin(rng), boost::end(rng));
Chris@16 34 return rng;
Chris@16 35 }
Chris@16 36
Chris@16 37 /// \overload
Chris@16 38 template<class RandomAccessRange>
Chris@16 39 inline const RandomAccessRange& push_heap(const RandomAccessRange& rng)
Chris@16 40 {
Chris@16 41 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
Chris@16 42 std::push_heap(boost::begin(rng), boost::end(rng));
Chris@16 43 return rng;
Chris@16 44 }
Chris@16 45
Chris@16 46 /// \overload
Chris@16 47 template<class RandomAccessRange, class Compare>
Chris@16 48 inline RandomAccessRange& push_heap(RandomAccessRange& rng, Compare comp_pred)
Chris@16 49 {
Chris@16 50 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
Chris@16 51 std::push_heap(boost::begin(rng), boost::end(rng), comp_pred);
Chris@16 52 return rng;
Chris@16 53 }
Chris@16 54
Chris@16 55 /// \overload
Chris@16 56 template<class RandomAccessRange, class Compare>
Chris@16 57 inline const RandomAccessRange& push_heap(const RandomAccessRange& rng, Compare comp_pred)
Chris@16 58 {
Chris@16 59 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
Chris@16 60 std::push_heap(boost::begin(rng), boost::end(rng), comp_pred);
Chris@16 61 return rng;
Chris@16 62 }
Chris@16 63
Chris@16 64 /// \brief template function pop_heap
Chris@16 65 ///
Chris@16 66 /// range-based version of the pop_heap std algorithm
Chris@16 67 ///
Chris@16 68 /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
Chris@16 69 /// \pre Compare is a model of the BinaryPredicateConcept
Chris@16 70 template<class RandomAccessRange>
Chris@16 71 inline RandomAccessRange& pop_heap(RandomAccessRange& rng)
Chris@16 72 {
Chris@16 73 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
Chris@16 74 std::pop_heap(boost::begin(rng), boost::end(rng));
Chris@16 75 return rng;
Chris@16 76 }
Chris@16 77
Chris@16 78 /// \overload
Chris@16 79 template<class RandomAccessRange>
Chris@16 80 inline const RandomAccessRange& pop_heap(const RandomAccessRange& rng)
Chris@16 81 {
Chris@16 82 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
Chris@16 83 std::pop_heap(boost::begin(rng), boost::end(rng));
Chris@16 84 return rng;
Chris@16 85 }
Chris@16 86
Chris@16 87 /// \overload
Chris@16 88 template<class RandomAccessRange, class Compare>
Chris@16 89 inline RandomAccessRange& pop_heap(RandomAccessRange& rng, Compare comp_pred)
Chris@16 90 {
Chris@16 91 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
Chris@16 92 std::pop_heap(boost::begin(rng), boost::end(rng), comp_pred);
Chris@16 93 return rng;
Chris@16 94 }
Chris@16 95
Chris@16 96 /// \overload
Chris@16 97 template<class RandomAccessRange, class Compare>
Chris@16 98 inline const RandomAccessRange& pop_heap(const RandomAccessRange& rng, Compare comp_pred)
Chris@16 99 {
Chris@16 100 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
Chris@16 101 std::pop_heap(boost::begin(rng), boost::end(rng), comp_pred);
Chris@16 102 return rng;
Chris@16 103 }
Chris@16 104
Chris@16 105 /// \brief template function make_heap
Chris@16 106 ///
Chris@16 107 /// range-based version of the make_heap std algorithm
Chris@16 108 ///
Chris@16 109 /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
Chris@16 110 /// \pre Compare is a model of the BinaryPredicateConcept
Chris@16 111 template<class RandomAccessRange>
Chris@16 112 inline RandomAccessRange& make_heap(RandomAccessRange& rng)
Chris@16 113 {
Chris@16 114 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
Chris@16 115 std::make_heap(boost::begin(rng), boost::end(rng));
Chris@16 116 return rng;
Chris@16 117 }
Chris@16 118
Chris@16 119 /// \overload
Chris@16 120 template<class RandomAccessRange>
Chris@16 121 inline const RandomAccessRange& make_heap(const RandomAccessRange& rng)
Chris@16 122 {
Chris@16 123 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
Chris@16 124 std::make_heap(boost::begin(rng), boost::end(rng));
Chris@16 125 return rng;
Chris@16 126 }
Chris@16 127
Chris@16 128 /// \overload
Chris@16 129 template<class RandomAccessRange, class Compare>
Chris@16 130 inline RandomAccessRange& make_heap(RandomAccessRange& rng, Compare comp_pred)
Chris@16 131 {
Chris@16 132 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
Chris@16 133 std::make_heap(boost::begin(rng), boost::end(rng), comp_pred);
Chris@16 134 return rng;
Chris@16 135 }
Chris@16 136
Chris@16 137 /// \overload
Chris@16 138 template<class RandomAccessRange, class Compare>
Chris@16 139 inline const RandomAccessRange& make_heap(const RandomAccessRange& rng, Compare comp_pred)
Chris@16 140 {
Chris@16 141 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
Chris@16 142 std::make_heap(boost::begin(rng), boost::end(rng), comp_pred);
Chris@16 143 return rng;
Chris@16 144 }
Chris@16 145
Chris@16 146 /// \brief template function sort_heap
Chris@16 147 ///
Chris@16 148 /// range-based version of the sort_heap std algorithm
Chris@16 149 ///
Chris@16 150 /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
Chris@16 151 /// \pre Compare is a model of the BinaryPredicateConcept
Chris@16 152 template<class RandomAccessRange>
Chris@16 153 inline RandomAccessRange& sort_heap(RandomAccessRange& rng)
Chris@16 154 {
Chris@16 155 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
Chris@16 156 std::sort_heap(boost::begin(rng), boost::end(rng));
Chris@16 157 return rng;
Chris@16 158 }
Chris@16 159
Chris@16 160 /// \overload
Chris@16 161 template<class RandomAccessRange>
Chris@16 162 inline const RandomAccessRange& sort_heap(const RandomAccessRange& rng)
Chris@16 163 {
Chris@16 164 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
Chris@16 165 std::sort_heap(boost::begin(rng), boost::end(rng));
Chris@16 166 return rng;
Chris@16 167 }
Chris@16 168
Chris@16 169 /// \overload
Chris@16 170 template<class RandomAccessRange, class Compare>
Chris@16 171 inline RandomAccessRange& sort_heap(RandomAccessRange& rng, Compare comp_pred)
Chris@16 172 {
Chris@16 173 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
Chris@16 174 std::sort_heap(boost::begin(rng), boost::end(rng), comp_pred);
Chris@16 175 return rng;
Chris@16 176 }
Chris@16 177
Chris@16 178 /// \overload
Chris@16 179 template<class RandomAccessRange, class Compare>
Chris@16 180 inline const RandomAccessRange& sort_heap(const RandomAccessRange& rng, Compare comp_pred)
Chris@16 181 {
Chris@16 182 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
Chris@16 183 std::sort_heap(boost::begin(rng), boost::end(rng), comp_pred);
Chris@16 184 return rng;
Chris@16 185 }
Chris@16 186
Chris@16 187 } // namespace range
Chris@16 188 using range::push_heap;
Chris@16 189 using range::pop_heap;
Chris@16 190 using range::make_heap;
Chris@16 191 using range::sort_heap;
Chris@16 192 } // namespace boost
Chris@16 193
Chris@16 194 #endif // include guard