]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/include/boost/compute/algorithm/unique.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / compute / include / 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 /// \see unique_copy()
35 template<class InputIterator, class BinaryPredicate>
36 inline InputIterator unique(InputIterator first,
37 InputIterator last,
38 BinaryPredicate op,
39 command_queue &queue = system::default_queue())
40 {
41 typedef typename std::iterator_traits<InputIterator>::value_type value_type;
42
43 vector<value_type> temp(first, last, queue);
44
45 return ::boost::compute::unique_copy(
46 temp.begin(), temp.end(), first, op, queue
47 );
48 }
49
50 /// \overload
51 template<class InputIterator>
52 inline InputIterator unique(InputIterator first,
53 InputIterator last,
54 command_queue &queue = system::default_queue())
55 {
56 typedef typename std::iterator_traits<InputIterator>::value_type value_type;
57
58 return ::boost::compute::unique(
59 first, last, ::boost::compute::equal_to<value_type>(), queue
60 );
61 }
62
63 } // end compute namespace
64 } // end boost namespace
65
66 #endif // BOOST_COMPUTE_ALGORITHM_UNIQUE_HPP