• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
3 //
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7 //
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
10 
11 #ifndef BOOST_COMPUTE_ALGORITHM_EQUAL_RANGE_HPP
12 #define BOOST_COMPUTE_ALGORITHM_EQUAL_RANGE_HPP
13 
14 #include <utility>
15 
16 #include <boost/static_assert.hpp>
17 
18 #include <boost/compute/system.hpp>
19 #include <boost/compute/command_queue.hpp>
20 #include <boost/compute/algorithm/lower_bound.hpp>
21 #include <boost/compute/algorithm/upper_bound.hpp>
22 #include <boost/compute/type_traits/is_device_iterator.hpp>
23 
24 namespace boost {
25 namespace compute {
26 
27 /// Returns a pair of iterators containing the range of values equal
28 /// to \p value in the sorted range [\p first, \p last).
29 ///
30 /// Space complexity: \Omega(1)
31 template<class InputIterator, class T>
32 inline std::pair<InputIterator, InputIterator>
equal_range(InputIterator first,InputIterator last,const T & value,command_queue & queue=system::default_queue ())33 equal_range(InputIterator first,
34             InputIterator last,
35             const T &value,
36             command_queue &queue = system::default_queue())
37 {
38     BOOST_STATIC_ASSERT(is_device_iterator<InputIterator>::value);
39     return std::make_pair(
40                ::boost::compute::lower_bound(first, last, value, queue),
41                ::boost::compute::upper_bound(first, last, value, queue)
42            );
43 }
44 
45 } // end compute namespace
46 } // end boost namespace
47 
48 #endif // BOOST_COMPUTE_ALGORITHM_EQUAL_RANGE_HPP
49