source: XIOS/dev/dev_olga/src/extern/boost/include/boost/range/algorithm/partial_sort_copy.hpp @ 1022

Last change on this file since 1022 was 1022, checked in by mhnguyen, 7 years ago
File size: 2.8 KB
Line 
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_COPY_HPP_INCLUDED
10#define BOOST_RANGE_ALGORITHM_PARTIAL_SORT_COPY_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 <boost/range/value_type.hpp>
17#include <algorithm>
18
19namespace boost
20{
21    namespace range
22    {
23
24/// \brief template function partial_sort_copy
25///
26/// range-based version of the partial_sort_copy std algorithm
27///
28/// \pre SinglePassRange is a model of the SinglePassRangeConcept
29/// \pre RandomAccessRange is a model of the Mutable_RandomAccessRangeConcept
30/// \pre BinaryPredicate is a model of the BinaryPredicateConcept
31template<class SinglePassRange, class RandomAccessRange>
32inline BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type
33partial_sort_copy(const SinglePassRange& rng1, RandomAccessRange& rng2)
34{
35    BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<const SinglePassRange>));
36
37    return std::partial_sort_copy(boost::begin(rng1), boost::end(rng1),
38        boost::begin(rng2), boost::end(rng2));
39}
40
41/// \overload
42template<class SinglePassRange, class RandomAccessRange>
43inline BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type
44partial_sort_copy(const SinglePassRange& rng1, const RandomAccessRange& rng2)
45{
46    BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<const SinglePassRange>));
47
48    return std::partial_sort_copy(boost::begin(rng1), boost::end(rng1),
49        boost::begin(rng2), boost::end(rng2));
50}
51
52/// \overload
53template<class SinglePassRange, class RandomAccessRange,
54         class BinaryPredicate>
55inline BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type
56partial_sort_copy(const SinglePassRange& rng1, RandomAccessRange& rng2,
57    BinaryPredicate pred)
58{
59    BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<const SinglePassRange>));
60
61    return std::partial_sort_copy(boost::begin(rng1), boost::end(rng1),
62        boost::begin(rng2), boost::end(rng2), pred);
63}
64
65/// \overload
66template<class SinglePassRange, class RandomAccessRange,
67         class BinaryPredicate>
68inline BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type
69partial_sort_copy(const SinglePassRange& rng1, const RandomAccessRange& rng2,
70    BinaryPredicate pred)
71{
72    BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<const SinglePassRange>));
73
74    return std::partial_sort_copy(boost::begin(rng1), boost::end(rng1),
75        boost::begin(rng2), boost::end(rng2), pred);
76}
77
78    } // namespace range
79    using range::partial_sort_copy;
80} // namespace boost
81
82#endif // include guard
Note: See TracBrowser for help on using the repository browser.