Chris@16: // Copyright Neil Groves 2009. Use, modification and Chris@16: // distribution is subject to the Boost Software License, Version Chris@16: // 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // Chris@16: // For more information, see http://www.boost.org/libs/range/ Chris@16: // Chris@16: #ifndef BOOST_RANGE_ALGORITHM_HEAP_ALGORITHM_HPP_INCLUDED Chris@16: #define BOOST_RANGE_ALGORITHM_HEAP_ALGORITHM_HPP_INCLUDED Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost Chris@16: { Chris@16: namespace range Chris@16: { Chris@16: Chris@16: /// \brief template function push_heap Chris@16: /// Chris@16: /// range-based version of the push_heap std algorithm Chris@16: /// Chris@16: /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept Chris@16: /// \pre Compare is a model of the BinaryPredicateConcept Chris@16: template Chris@16: inline RandomAccessRange& push_heap(RandomAccessRange& rng) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); Chris@16: std::push_heap(boost::begin(rng), boost::end(rng)); Chris@16: return rng; Chris@16: } Chris@16: Chris@16: /// \overload Chris@16: template Chris@16: inline const RandomAccessRange& push_heap(const RandomAccessRange& rng) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); Chris@16: std::push_heap(boost::begin(rng), boost::end(rng)); Chris@16: return rng; Chris@16: } Chris@16: Chris@16: /// \overload Chris@16: template Chris@16: inline RandomAccessRange& push_heap(RandomAccessRange& rng, Compare comp_pred) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); Chris@16: std::push_heap(boost::begin(rng), boost::end(rng), comp_pred); Chris@16: return rng; Chris@16: } Chris@16: Chris@16: /// \overload Chris@16: template Chris@16: inline const RandomAccessRange& push_heap(const RandomAccessRange& rng, Compare comp_pred) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); Chris@16: std::push_heap(boost::begin(rng), boost::end(rng), comp_pred); Chris@16: return rng; Chris@16: } Chris@16: Chris@16: /// \brief template function pop_heap Chris@16: /// Chris@16: /// range-based version of the pop_heap std algorithm Chris@16: /// Chris@16: /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept Chris@16: /// \pre Compare is a model of the BinaryPredicateConcept Chris@16: template Chris@16: inline RandomAccessRange& pop_heap(RandomAccessRange& rng) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); Chris@16: std::pop_heap(boost::begin(rng), boost::end(rng)); Chris@16: return rng; Chris@16: } Chris@16: Chris@16: /// \overload Chris@16: template Chris@16: inline const RandomAccessRange& pop_heap(const RandomAccessRange& rng) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); Chris@16: std::pop_heap(boost::begin(rng), boost::end(rng)); Chris@16: return rng; Chris@16: } Chris@16: Chris@16: /// \overload Chris@16: template Chris@16: inline RandomAccessRange& pop_heap(RandomAccessRange& rng, Compare comp_pred) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); Chris@16: std::pop_heap(boost::begin(rng), boost::end(rng), comp_pred); Chris@16: return rng; Chris@16: } Chris@16: Chris@16: /// \overload Chris@16: template Chris@16: inline const RandomAccessRange& pop_heap(const RandomAccessRange& rng, Compare comp_pred) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); Chris@16: std::pop_heap(boost::begin(rng), boost::end(rng), comp_pred); Chris@16: return rng; Chris@16: } Chris@16: Chris@16: /// \brief template function make_heap Chris@16: /// Chris@16: /// range-based version of the make_heap std algorithm Chris@16: /// Chris@16: /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept Chris@16: /// \pre Compare is a model of the BinaryPredicateConcept Chris@16: template Chris@16: inline RandomAccessRange& make_heap(RandomAccessRange& rng) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); Chris@16: std::make_heap(boost::begin(rng), boost::end(rng)); Chris@16: return rng; Chris@16: } Chris@16: Chris@16: /// \overload Chris@16: template Chris@16: inline const RandomAccessRange& make_heap(const RandomAccessRange& rng) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); Chris@16: std::make_heap(boost::begin(rng), boost::end(rng)); Chris@16: return rng; Chris@16: } Chris@16: Chris@16: /// \overload Chris@16: template Chris@16: inline RandomAccessRange& make_heap(RandomAccessRange& rng, Compare comp_pred) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); Chris@16: std::make_heap(boost::begin(rng), boost::end(rng), comp_pred); Chris@16: return rng; Chris@16: } Chris@16: Chris@16: /// \overload Chris@16: template Chris@16: inline const RandomAccessRange& make_heap(const RandomAccessRange& rng, Compare comp_pred) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); Chris@16: std::make_heap(boost::begin(rng), boost::end(rng), comp_pred); Chris@16: return rng; Chris@16: } Chris@16: Chris@16: /// \brief template function sort_heap Chris@16: /// Chris@16: /// range-based version of the sort_heap std algorithm Chris@16: /// Chris@16: /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept Chris@16: /// \pre Compare is a model of the BinaryPredicateConcept Chris@16: template Chris@16: inline RandomAccessRange& sort_heap(RandomAccessRange& rng) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); Chris@16: std::sort_heap(boost::begin(rng), boost::end(rng)); Chris@16: return rng; Chris@16: } Chris@16: Chris@16: /// \overload Chris@16: template Chris@16: inline const RandomAccessRange& sort_heap(const RandomAccessRange& rng) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); Chris@16: std::sort_heap(boost::begin(rng), boost::end(rng)); Chris@16: return rng; Chris@16: } Chris@16: Chris@16: /// \overload Chris@16: template Chris@16: inline RandomAccessRange& sort_heap(RandomAccessRange& rng, Compare comp_pred) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); Chris@16: std::sort_heap(boost::begin(rng), boost::end(rng), comp_pred); Chris@16: return rng; Chris@16: } Chris@16: Chris@16: /// \overload Chris@16: template Chris@16: inline const RandomAccessRange& sort_heap(const RandomAccessRange& rng, Compare comp_pred) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); Chris@16: std::sort_heap(boost::begin(rng), boost::end(rng), comp_pred); Chris@16: return rng; Chris@16: } Chris@16: Chris@16: } // namespace range Chris@16: using range::push_heap; Chris@16: using range::pop_heap; Chris@16: using range::make_heap; Chris@16: using range::sort_heap; Chris@16: } // namespace boost Chris@16: Chris@16: #endif // include guard