File indexing completed on 2025-12-16 09:44:30
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_COMPUTE_ALGORITHM_BINARY_SEARCH_HPP
0012 #define BOOST_COMPUTE_ALGORITHM_BINARY_SEARCH_HPP
0013
0014 #include <boost/static_assert.hpp>
0015
0016 #include <boost/compute/system.hpp>
0017 #include <boost/compute/command_queue.hpp>
0018 #include <boost/compute/algorithm/lower_bound.hpp>
0019 #include <boost/compute/type_traits/is_device_iterator.hpp>
0020
0021 namespace boost {
0022 namespace compute {
0023
0024
0025
0026
0027
0028 template<class InputIterator, class T>
0029 inline bool binary_search(InputIterator first,
0030 InputIterator last,
0031 const T &value,
0032 command_queue &queue = system::default_queue())
0033 {
0034 BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
0035 InputIterator position = lower_bound(first, last, value, queue);
0036
0037 return position != last && position.read(queue) == value;
0038 }
0039
0040 }
0041 }
0042
0043 #endif