Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:57

0001 //---------------------------------------------------------------------------//
0002 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
0003 //
0004 // Distributed under the Boost Software License, Version 1.0
0005 // See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt
0007 //
0008 // See http://boostorg.github.com/compute for more information.
0009 //---------------------------------------------------------------------------//
0010 
0011 #ifndef BOOST_COMPUTE_ALGORITHM_REMOVE_HPP
0012 #define BOOST_COMPUTE_ALGORITHM_REMOVE_HPP
0013 
0014 #include <boost/static_assert.hpp>
0015 
0016 #include <boost/compute/lambda.hpp>
0017 #include <boost/compute/system.hpp>
0018 #include <boost/compute/algorithm/remove_if.hpp>
0019 #include <boost/compute/type_traits/vector_size.hpp>
0020 #include <boost/compute/type_traits/is_device_iterator.hpp>
0021 
0022 namespace boost {
0023 namespace compute {
0024 
0025 /// Removes each element equal to \p value in the range [\p first,
0026 /// \p last).
0027 ///
0028 /// Space complexity: \Omega(3n)
0029 ///
0030 /// \see remove_if()
0031 template<class Iterator, class T>
0032 inline Iterator remove(Iterator first,
0033                        Iterator last,
0034                        const T &value,
0035                        command_queue &queue = system::default_queue())
0036 {
0037     BOOST_STATIC_ASSERT(is_device_iterator<Iterator>::value);
0038     typedef typename std::iterator_traits<Iterator>::value_type value_type;
0039 
0040     using ::boost::compute::_1;
0041     using ::boost::compute::lambda::all;
0042 
0043     if(vector_size<value_type>::value == 1){
0044         return ::boost::compute::remove_if(first,
0045                                            last,
0046                                            _1 == value,
0047                                            queue);
0048     }
0049     else {
0050         return ::boost::compute::remove_if(first,
0051                                            last,
0052                                            all(_1 == value),
0053                                            queue);
0054     }
0055 }
0056 
0057 } // end compute namespace
0058 } // end boost namespace
0059 
0060 #endif // BOOST_COMPUTE_ALGORITHM_REMOVE_HPP