1 // Copyright Neil Groves 2009. Use, modification and
2 // distribution is subject to the Boost Software License, Version
3 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
7 // For more information, see http://www.boost.org/libs/range/
9 #ifndef BOOST_RANGE_ALGORITHM_PARTIAL_SORT_HPP_INCLUDED
10 #define BOOST_RANGE_ALGORITHM_PARTIAL_SORT_HPP_INCLUDED
12 #include <boost/concept_check.hpp>
13 #include <boost/range/begin.hpp>
14 #include <boost/range/end.hpp>
15 #include <boost/range/concepts.hpp>
23 /// \brief template function partial_sort
25 /// range-based version of the partial_sort std algorithm
27 /// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
28 /// \pre BinaryPredicate is a model of the BinaryPredicateConcept
29 template<class RandomAccessRange>
30 inline RandomAccessRange& partial_sort(RandomAccessRange& rng,
31 BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type middle)
33 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
34 std::partial_sort(boost::begin(rng), middle, boost::end(rng));
39 template<class RandomAccessRange>
40 inline const RandomAccessRange& partial_sort(const RandomAccessRange& rng,
41 BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type middle)
43 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
44 std::partial_sort(boost::begin(rng), middle, boost::end(rng));
49 template<class RandomAccessRange, class BinaryPredicate>
50 inline RandomAccessRange& partial_sort(RandomAccessRange& rng,
51 BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type middle,
52 BinaryPredicate sort_pred)
54 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
55 std::partial_sort(boost::begin(rng), middle, boost::end(rng),
61 template<class RandomAccessRange, class BinaryPredicate>
62 inline const RandomAccessRange& partial_sort(const RandomAccessRange& rng,
63 BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type middle,
64 BinaryPredicate sort_pred)
66 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
67 std::partial_sort(boost::begin(rng), middle, boost::end(rng),
73 using range::partial_sort;
76 #endif // include guard