]>
Commit | Line | Data |
---|---|---|
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_REMOVE_HPP | |
12 | #define BOOST_COMPUTE_ALGORITHM_REMOVE_HPP | |
13 | ||
14 | #include <boost/compute/lambda.hpp> | |
15 | #include <boost/compute/system.hpp> | |
16 | #include <boost/compute/algorithm/remove_if.hpp> | |
17 | #include <boost/compute/type_traits/vector_size.hpp> | |
18 | ||
19 | namespace boost { | |
20 | namespace compute { | |
21 | ||
22 | /// Removes each element equal to \p value in the range [\p first, | |
23 | /// \p last). | |
24 | /// | |
25 | /// \see remove_if() | |
26 | template<class Iterator, class T> | |
27 | inline Iterator remove(Iterator first, | |
28 | Iterator last, | |
29 | const T &value, | |
30 | command_queue &queue = system::default_queue()) | |
31 | { | |
32 | typedef typename std::iterator_traits<Iterator>::value_type value_type; | |
33 | ||
34 | using ::boost::compute::_1; | |
35 | using ::boost::compute::lambda::all; | |
36 | ||
37 | if(vector_size<value_type>::value == 1){ | |
38 | return ::boost::compute::remove_if(first, | |
39 | last, | |
40 | _1 == value, | |
41 | queue); | |
42 | } | |
43 | else { | |
44 | return ::boost::compute::remove_if(first, | |
45 | last, | |
46 | all(_1 == value), | |
47 | queue); | |
48 | } | |
49 | } | |
50 | ||
51 | } // end compute namespace | |
52 | } // end boost namespace | |
53 | ||
54 | #endif // BOOST_COMPUTE_ALGORITHM_REMOVE_HPP |