1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2014 Roshan <thisisroshansmail@gmail.com>
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
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
11 #ifndef BOOST_COMPUTE_ALGORITHM_UNIQUE_HPP
12 #define BOOST_COMPUTE_ALGORITHM_UNIQUE_HPP
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>
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
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
32 /// \return \c InputIterator to the new logical end of the range
34 /// \see unique_copy()
35 template<class InputIterator, class BinaryPredicate>
36 inline InputIterator unique(InputIterator first,
39 command_queue &queue = system::default_queue())
41 typedef typename std::iterator_traits<InputIterator>::value_type value_type;
43 vector<value_type> temp(first, last, queue);
45 return ::boost::compute::unique_copy(
46 temp.begin(), temp.end(), first, op, queue
51 template<class InputIterator>
52 inline InputIterator unique(InputIterator first,
54 command_queue &queue = system::default_queue())
56 typedef typename std::iterator_traits<InputIterator>::value_type value_type;
58 return ::boost::compute::unique(
59 first, last, ::boost::compute::equal_to<value_type>(), queue
63 } // end compute namespace
64 } // end boost namespace
66 #endif // BOOST_COMPUTE_ALGORITHM_UNIQUE_HPP