]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/include/boost/compute/algorithm/minmax_element.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / compute / include / boost / compute / algorithm / minmax_element.hpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
3 //
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7 //
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
10
11 #ifndef BOOST_COMPUTE_ALGORITHM_MINMAX_ELEMENT_HPP
12 #define BOOST_COMPUTE_ALGORITHM_MINMAX_ELEMENT_HPP
13
14 #include <utility>
15
16 #include <boost/compute/system.hpp>
17 #include <boost/compute/command_queue.hpp>
18 #include <boost/compute/algorithm/max_element.hpp>
19 #include <boost/compute/algorithm/min_element.hpp>
20
21 namespace boost {
22 namespace compute {
23
24 /// Returns a pair of iterators with the first pointing to the minimum
25 /// element and the second pointing to the maximum element in the range
26 /// [\p first, \p last).
27 ///
28 /// \param first first element in the input range
29 /// \param last last element in the input range
30 /// \param compare comparison function object which returns true if the first
31 /// argument is less than (i.e. is ordered before) the second.
32 /// \param queue command queue to perform the operation
33 ///
34 /// \see max_element(), min_element()
35 template<class InputIterator, class Compare>
36 inline std::pair<InputIterator, InputIterator>
37 minmax_element(InputIterator first,
38 InputIterator last,
39 Compare compare,
40 command_queue &queue = system::default_queue())
41 {
42 if(first == last){
43 // empty range
44 return std::make_pair(first, first);
45 }
46
47 return std::make_pair(min_element(first, last, compare, queue),
48 max_element(first, last, compare, queue));
49 }
50
51 ///\overload
52 template<class InputIterator>
53 inline std::pair<InputIterator, InputIterator>
54 minmax_element(InputIterator first,
55 InputIterator last,
56 command_queue &queue = system::default_queue())
57 {
58 if(first == last){
59 // empty range
60 return std::make_pair(first, first);
61 }
62
63 return std::make_pair(min_element(first, last, queue),
64 max_element(first, last, queue));
65 }
66
67 } // end compute namespace
68 } // end boost namespace
69
70 #endif // BOOST_COMPUTE_ALGORITHM_MINMAX_ELEMENT_HPP