]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/range/include/boost/range/algorithm/partial_sort.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / range / include / boost / range / algorithm / partial_sort.hpp
CommitLineData
7c673cae
FG
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)
5//
6//
7// For more information, see http://www.boost.org/libs/range/
8//
9#ifndef BOOST_RANGE_ALGORITHM_PARTIAL_SORT_HPP_INCLUDED
10#define BOOST_RANGE_ALGORITHM_PARTIAL_SORT_HPP_INCLUDED
11
12#include <boost/concept_check.hpp>
13#include <boost/range/begin.hpp>
14#include <boost/range/end.hpp>
15#include <boost/range/concepts.hpp>
16#include <algorithm>
17
18namespace boost
19{
20 namespace range
21 {
22
23/// \brief template function partial_sort
24///
25/// range-based version of the partial_sort std algorithm
26///
27/// \pre RandomAccessRange is a model of the RandomAccessRangeConcept
28/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
29template<class RandomAccessRange>
30inline RandomAccessRange& partial_sort(RandomAccessRange& rng,
31 BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type middle)
32{
33 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
34 std::partial_sort(boost::begin(rng), middle, boost::end(rng));
35 return rng;
36}
37
38/// \overload
39template<class RandomAccessRange>
40inline const RandomAccessRange& partial_sort(const RandomAccessRange& rng,
41 BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type middle)
42{
43 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
44 std::partial_sort(boost::begin(rng), middle, boost::end(rng));
45 return rng;
46}
47
48/// \overload
49template<class RandomAccessRange, class BinaryPredicate>
50inline RandomAccessRange& partial_sort(RandomAccessRange& rng,
51 BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type middle,
52 BinaryPredicate sort_pred)
53{
54 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
55 std::partial_sort(boost::begin(rng), middle, boost::end(rng),
56 sort_pred);
57 return rng;
58}
59
60/// \overload
61template<class RandomAccessRange, class BinaryPredicate>
62inline const RandomAccessRange& partial_sort(const RandomAccessRange& rng,
63 BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type middle,
64 BinaryPredicate sort_pred)
65{
66 BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
67 std::partial_sort(boost::begin(rng), middle, boost::end(rng),
68 sort_pred);
69 return rng;
70}
71
72 } // namespace range
73 using range::partial_sort;
74} // namespace boost
75
76#endif // include guard