]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/compute/algorithm/unique.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / compute / algorithm / unique.hpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2014 Roshan <thisisroshansmail@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_UNIQUE_HPP
12 #define BOOST_COMPUTE_ALGORITHM_UNIQUE_HPP
13
14 #include <boost/compute/system.hpp>
15 #include <boost/compute/command_queue.hpp>
16 #include <boost/compute/algorithm/unique_copy.hpp>
17 #include <boost/compute/container/vector.hpp>
18 #include <boost/compute/functional/operator.hpp>
19
20 namespace boost {
21 namespace compute {
22
23 /// Removes all consecutive duplicate elements (determined by \p op) from the
24 /// range [first, last). If \p op is not provided, the equality operator is
25 /// used.
26 ///
27 /// \param first first element in the input range
28 /// \param last last element in the input range
29 /// \param op binary operator used to check for uniqueness
30 /// \param queue command queue to perform the operation
31 ///
32 /// \return \c InputIterator to the new logical end of the range
33 ///
34 /// Space complexity: \Omega(4n)
35 ///
36 /// \see unique_copy()
37 template<class InputIterator, class BinaryPredicate>
38 inline InputIterator unique(InputIterator first,
39 InputIterator last,
40 BinaryPredicate op,
41 command_queue &queue = system::default_queue())
42 {
43 typedef typename std::iterator_traits<InputIterator>::value_type value_type;
44
45 vector<value_type> temp(first, last, queue);
46
47 return ::boost::compute::unique_copy(
48 temp.begin(), temp.end(), first, op, queue
49 );
50 }
51
52 /// \overload
53 template<class InputIterator>
54 inline InputIterator unique(InputIterator first,
55 InputIterator last,
56 command_queue &queue = system::default_queue())
57 {
58 typedef typename std::iterator_traits<InputIterator>::value_type value_type;
59
60 return ::boost::compute::unique(
61 first, last, ::boost::compute::equal_to<value_type>(), queue
62 );
63 }
64
65 } // end compute namespace
66 } // end boost namespace
67
68 #endif // BOOST_COMPUTE_ALGORITHM_UNIQUE_HPP