1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@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_REMOVE_IF_HPP
12 #define BOOST_COMPUTE_ALGORITHM_REMOVE_IF_HPP
14 #include <boost/compute/system.hpp>
15 #include <boost/compute/algorithm/copy_if.hpp>
16 #include <boost/compute/container/vector.hpp>
17 #include <boost/compute/functional/logical.hpp>
22 /// Removes each element for which \p predicate returns \c true in the
23 /// range [\p first, \p last).
25 /// Space complexity: \Omega(3n)
28 template<class Iterator, class Predicate>
29 inline Iterator remove_if(Iterator first,
32 command_queue &queue = system::default_queue())
34 typedef typename std::iterator_traits<Iterator>::value_type value_type;
36 // temporary storage for the input data
37 ::boost::compute::vector<value_type> tmp(first, last, queue);
39 return ::boost::compute::copy_if(tmp.begin(),
46 } // end compute namespace
47 } // end boost namespace
49 #endif // BOOST_COMPUTE_ALGORITHM_REMOVE_IF_HPP