1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #ifndef BOOST_COMPUTE_ALGORITHM_IS_SORTED_HPP
- #define BOOST_COMPUTE_ALGORITHM_IS_SORTED_HPP
- #include <boost/static_assert.hpp>
- #include <boost/compute/command_queue.hpp>
- #include <boost/compute/system.hpp>
- #include <boost/compute/functional/bind.hpp>
- #include <boost/compute/functional/operator.hpp>
- #include <boost/compute/algorithm/adjacent_find.hpp>
- #include <boost/compute/type_traits/is_device_iterator.hpp>
- namespace boost {
- namespace compute {
- template<class InputIterator, class Compare>
- inline bool is_sorted(InputIterator first,
- InputIterator last,
- Compare compare,
- command_queue &queue = system::default_queue())
- {
- BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
- using ::boost::compute::placeholders::_1;
- using ::boost::compute::placeholders::_2;
- return ::boost::compute::adjacent_find(
- first, last, ::boost::compute::bind(compare, _2, _1), queue
- ) == last;
- }
- template<class InputIterator>
- inline bool is_sorted(InputIterator first,
- InputIterator last,
- command_queue &queue = system::default_queue())
- {
- BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
- typedef typename std::iterator_traits<InputIterator>::value_type value_type;
- return ::boost::compute::is_sorted(
- first, last, ::boost::compute::less<value_type>(), queue
- );
- }
- }
- }
- #endif
|