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_IS_SORTED_HPP
0012 #define BOOST_COMPUTE_ALGORITHM_IS_SORTED_HPP
0013
0014 #include <boost/static_assert.hpp>
0015
0016 #include <boost/compute/command_queue.hpp>
0017 #include <boost/compute/system.hpp>
0018 #include <boost/compute/functional/bind.hpp>
0019 #include <boost/compute/functional/operator.hpp>
0020 #include <boost/compute/algorithm/adjacent_find.hpp>
0021 #include <boost/compute/type_traits/is_device_iterator.hpp>
0022
0023 namespace boost {
0024 namespace compute {
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 template<class InputIterator, class Compare>
0040 inline bool is_sorted(InputIterator first,
0041 InputIterator last,
0042 Compare compare,
0043 command_queue &queue = system::default_queue())
0044 {
0045 BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
0046 using ::boost::compute::placeholders::_1;
0047 using ::boost::compute::placeholders::_2;
0048
0049 return ::boost::compute::adjacent_find(
0050 first, last, ::boost::compute::bind(compare, _2, _1), queue
0051 ) == last;
0052 }
0053
0054
0055 template<class InputIterator>
0056 inline bool is_sorted(InputIterator first,
0057 InputIterator last,
0058 command_queue &queue = system::default_queue())
0059 {
0060 BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
0061 typedef typename std::iterator_traits<InputIterator>::value_type value_type;
0062
0063 return ::boost::compute::is_sorted(
0064 first, last, ::boost::compute::less<value_type>(), queue
0065 );
0066 }
0067
0068 }
0069 }
0070
0071 #endif