File indexing completed on 2025-01-18 09:29:56
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_COMPUTE_ALGORITHM_MINMAX_ELEMENT_HPP
0012 #define BOOST_COMPUTE_ALGORITHM_MINMAX_ELEMENT_HPP
0013
0014 #include <utility>
0015
0016 #include <boost/static_assert.hpp>
0017
0018 #include <boost/compute/system.hpp>
0019 #include <boost/compute/command_queue.hpp>
0020 #include <boost/compute/algorithm/max_element.hpp>
0021 #include <boost/compute/algorithm/min_element.hpp>
0022 #include <boost/compute/type_traits/is_device_iterator.hpp>
0023
0024 namespace boost {
0025 namespace compute {
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041 template<class InputIterator, class Compare>
0042 inline std::pair<InputIterator, InputIterator>
0043 minmax_element(InputIterator first,
0044 InputIterator last,
0045 Compare compare,
0046 command_queue &queue = system::default_queue())
0047 {
0048 BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
0049 if(first == last){
0050
0051 return std::make_pair(first, first);
0052 }
0053
0054 return std::make_pair(min_element(first, last, compare, queue),
0055 max_element(first, last, compare, queue));
0056 }
0057
0058
0059 template<class InputIterator>
0060 inline std::pair<InputIterator, InputIterator>
0061 minmax_element(InputIterator first,
0062 InputIterator last,
0063 command_queue &queue = system::default_queue())
0064 {
0065 BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
0066 if(first == last){
0067
0068 return std::make_pair(first, first);
0069 }
0070
0071 return std::make_pair(min_element(first, last, queue),
0072 max_element(first, last, queue));
0073 }
0074
0075 }
0076 }
0077
0078 #endif