2 * Copyright 2008-2013 NVIDIA Corporation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 * \brief Inline file for remove.h.
22 #include <thrust/detail/config.h>
23 #include <thrust/remove.h>
24 #include <thrust/iterator/iterator_traits.h>
25 #include <thrust/system/detail/generic/select_system.h>
26 #include <thrust/system/detail/generic/remove.h>
27 #include <thrust/system/detail/adl/remove.h>
33 template<typename DerivedPolicy,
34 typename ForwardIterator,
36 ForwardIterator remove(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
37 ForwardIterator first,
41 using thrust::system::detail::generic::remove;
42 return remove(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, value);
46 template<typename DerivedPolicy,
47 typename InputIterator,
48 typename OutputIterator,
50 OutputIterator remove_copy(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
53 OutputIterator result,
56 using thrust::system::detail::generic::remove_copy;
57 return remove_copy(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, result, value);
58 } // end remove_copy()
61 template<typename DerivedPolicy,
62 typename ForwardIterator,
64 ForwardIterator remove_if(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
65 ForwardIterator first,
69 using thrust::system::detail::generic::remove_if;
70 return remove_if(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, pred);
74 template<typename DerivedPolicy,
75 typename InputIterator,
76 typename OutputIterator,
78 OutputIterator remove_copy_if(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
81 OutputIterator result,
84 using thrust::system::detail::generic::remove_copy_if;
85 return remove_copy_if(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, result, pred);
86 } // end remove_copy_if()
89 template<typename DerivedPolicy,
90 typename ForwardIterator,
91 typename InputIterator,
93 ForwardIterator remove_if(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
94 ForwardIterator first,
96 InputIterator stencil,
99 using thrust::system::detail::generic::remove_if;
100 return remove_if(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, stencil, pred);
104 template<typename DerivedPolicy,
105 typename InputIterator1,
106 typename InputIterator2,
107 typename OutputIterator,
109 OutputIterator remove_copy_if(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
110 InputIterator1 first,
112 InputIterator2 stencil,
113 OutputIterator result,
116 using thrust::system::detail::generic::remove_copy_if;
117 return remove_copy_if(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, stencil, result, pred);
118 } // end remove_copy_if()
121 template<typename ForwardIterator,
123 ForwardIterator remove(ForwardIterator first,
124 ForwardIterator last,
127 using thrust::system::detail::generic::select_system;
129 typedef typename thrust::iterator_system<ForwardIterator>::type System;
133 return thrust::remove(select_system(system), first, last, value);
137 template<typename InputIterator,
138 typename OutputIterator,
140 OutputIterator remove_copy(InputIterator first,
142 OutputIterator result,
145 using thrust::system::detail::generic::select_system;
147 typedef typename thrust::iterator_system<InputIterator>::type System1;
148 typedef typename thrust::iterator_system<OutputIterator>::type System2;
153 return thrust::remove_copy(select_system(system1,system2), first, last, result, value);
154 } // end remove_copy()
157 template<typename ForwardIterator,
159 ForwardIterator remove_if(ForwardIterator first,
160 ForwardIterator last,
163 using thrust::system::detail::generic::select_system;
165 typedef typename thrust::iterator_system<ForwardIterator>::type System;
169 return thrust::remove_if(select_system(system), first, last, pred);
173 template<typename ForwardIterator,
174 typename InputIterator,
176 ForwardIterator remove_if(ForwardIterator first,
177 ForwardIterator last,
178 InputIterator stencil,
181 using thrust::system::detail::generic::select_system;
183 typedef typename thrust::iterator_system<ForwardIterator>::type System1;
184 typedef typename thrust::iterator_system<InputIterator>::type System2;
189 return thrust::remove_if(select_system(system1,system2), first, last, stencil, pred);
193 template<typename InputIterator,
194 typename OutputIterator,
196 OutputIterator remove_copy_if(InputIterator first,
198 OutputIterator result,
201 using thrust::system::detail::generic::select_system;
203 typedef typename thrust::iterator_system<InputIterator>::type System1;
204 typedef typename thrust::iterator_system<OutputIterator>::type System2;
209 return thrust::remove_copy_if(select_system(system1,system2), first, last, result, pred);
210 } // end remove_copy_if()
213 template<typename InputIterator1,
214 typename InputIterator2,
215 typename OutputIterator,
217 OutputIterator remove_copy_if(InputIterator1 first,
219 InputIterator2 stencil,
220 OutputIterator result,
223 using thrust::system::detail::generic::select_system;
225 typedef typename thrust::iterator_system<InputIterator1>::type System1;
226 typedef typename thrust::iterator_system<InputIterator2>::type System2;
227 typedef typename thrust::iterator_system<OutputIterator>::type System3;
233 return thrust::remove_copy_if(select_system(system1,system2,system3), first, last, stencil, result, pred);
234 } // end remove_copy_if()
237 } // end namespace thrust