Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:58

0001 //---------------------------------------------------------------------------//
0002 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
0003 //
0004 // Distributed under the Boost Software License, Version 1.0
0005 // See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt
0007 //
0008 // See http://boostorg.github.com/compute for more information.
0009 //---------------------------------------------------------------------------//
0010 
0011 #ifndef BOOST_COMPUTE_ALGORITHM_UPPER_BOUND_HPP
0012 #define BOOST_COMPUTE_ALGORITHM_UPPER_BOUND_HPP
0013 
0014 #include <boost/static_assert.hpp>
0015 
0016 #include <boost/compute/lambda.hpp>
0017 #include <boost/compute/system.hpp>
0018 #include <boost/compute/command_queue.hpp>
0019 #include <boost/compute/algorithm/detail/binary_find.hpp>
0020 #include <boost/compute/type_traits/is_device_iterator.hpp>
0021 
0022 namespace boost {
0023 namespace compute {
0024 
0025 /// Returns an iterator pointing to the first element in the sorted
0026 /// range [\p first, \p last) that is not less than or equal to
0027 /// \p value.
0028 ///
0029 /// Space complexity: \Omega(1)
0030 template<class InputIterator, class T>
0031 inline InputIterator
0032 upper_bound(InputIterator first,
0033             InputIterator last,
0034             const T &value,
0035             command_queue &queue = system::default_queue())
0036 {
0037     BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
0038     using ::boost::compute::_1;
0039 
0040     InputIterator position =
0041         detail::binary_find(first, last, _1 > value, queue);
0042 
0043     return position;
0044 }
0045 
0046 } // end compute namespace
0047 } // end boost namespace
0048 
0049 #endif // BOOST_COMPUTE_ALGORITHM_UPPER_BOUND_HPP