OSDN Git Service

CUDA
[eos/hostdependX86LINUX64.git] / util / X86LINUX64 / cuda-6.5 / include / thrust / detail / remove.inl
1 /*
2  *  Copyright 2008-2013 NVIDIA Corporation
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17
18 /*! \file remove.inl
19  *  \brief Inline file for remove.h.
20  */
21
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>
28
29 namespace thrust
30 {
31
32
33 template<typename DerivedPolicy,
34          typename ForwardIterator,
35          typename T>
36   ForwardIterator remove(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
37                          ForwardIterator first,
38                          ForwardIterator last,
39                          const T &value)
40 {
41   using thrust::system::detail::generic::remove;
42   return remove(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, value);
43 } // end remove()
44
45
46 template<typename DerivedPolicy,
47          typename InputIterator,
48          typename OutputIterator,
49          typename T>
50   OutputIterator remove_copy(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
51                              InputIterator first,
52                              InputIterator last,
53                              OutputIterator result,
54                              const T &value)
55 {
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()
59
60
61 template<typename DerivedPolicy,
62          typename ForwardIterator,
63          typename Predicate>
64   ForwardIterator remove_if(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
65                             ForwardIterator first,
66                             ForwardIterator last,
67                             Predicate pred)
68 {
69   using thrust::system::detail::generic::remove_if;
70   return remove_if(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, pred);
71 } // end remove_if()
72
73
74 template<typename DerivedPolicy,
75          typename InputIterator,
76          typename OutputIterator,
77          typename Predicate>
78   OutputIterator remove_copy_if(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
79                                 InputIterator first,
80                                 InputIterator last,
81                                 OutputIterator result,
82                                 Predicate pred)
83 {
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()
87
88
89 template<typename DerivedPolicy,
90          typename ForwardIterator,
91          typename InputIterator,
92          typename Predicate>
93   ForwardIterator remove_if(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
94                             ForwardIterator first,
95                             ForwardIterator last,
96                             InputIterator stencil,
97                             Predicate pred)
98 {
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);
101 } // end remove_if()
102
103
104 template<typename DerivedPolicy,
105          typename InputIterator1,
106          typename InputIterator2,
107          typename OutputIterator,
108          typename Predicate>
109   OutputIterator remove_copy_if(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
110                                 InputIterator1 first,
111                                 InputIterator1 last,
112                                 InputIterator2 stencil,
113                                 OutputIterator result,
114                                 Predicate pred)
115 {
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()
119
120
121 template<typename ForwardIterator,
122          typename T>
123   ForwardIterator remove(ForwardIterator first,
124                          ForwardIterator last,
125                          const T &value)
126 {
127   using thrust::system::detail::generic::select_system;
128
129   typedef typename thrust::iterator_system<ForwardIterator>::type System;
130
131   System system;
132
133   return thrust::remove(select_system(system), first, last, value);
134 } // end remove()
135
136
137 template<typename InputIterator,
138          typename OutputIterator,
139          typename T>
140   OutputIterator remove_copy(InputIterator first,
141                              InputIterator last,
142                              OutputIterator result,
143                              const T &value)
144 {
145   using thrust::system::detail::generic::select_system;
146
147   typedef typename thrust::iterator_system<InputIterator>::type  System1;
148   typedef typename thrust::iterator_system<OutputIterator>::type System2;
149
150   System1 system1;
151   System2 system2;
152
153   return thrust::remove_copy(select_system(system1,system2), first, last, result, value);
154 } // end remove_copy()
155
156
157 template<typename ForwardIterator,
158          typename Predicate>
159   ForwardIterator remove_if(ForwardIterator first,
160                             ForwardIterator last,
161                             Predicate pred)
162 {
163   using thrust::system::detail::generic::select_system;
164
165   typedef typename thrust::iterator_system<ForwardIterator>::type System;
166
167   System system;
168
169   return thrust::remove_if(select_system(system), first, last, pred);
170 } // end remove_if()
171
172
173 template<typename ForwardIterator,
174          typename InputIterator,
175          typename Predicate>
176   ForwardIterator remove_if(ForwardIterator first,
177                             ForwardIterator last,
178                             InputIterator stencil,
179                             Predicate pred)
180 {
181   using thrust::system::detail::generic::select_system;
182
183   typedef typename thrust::iterator_system<ForwardIterator>::type System1;
184   typedef typename thrust::iterator_system<InputIterator>::type   System2;
185
186   System1 system1;
187   System2 system2;
188
189   return thrust::remove_if(select_system(system1,system2), first, last, stencil, pred);
190 } // end remove_if()
191
192
193 template<typename InputIterator,
194          typename OutputIterator,
195          typename Predicate>
196   OutputIterator remove_copy_if(InputIterator first,
197                                 InputIterator last,
198                                 OutputIterator result,
199                                 Predicate pred)
200 {
201   using thrust::system::detail::generic::select_system;
202
203   typedef typename thrust::iterator_system<InputIterator>::type  System1;
204   typedef typename thrust::iterator_system<OutputIterator>::type System2;
205
206   System1 system1;
207   System2 system2;
208
209   return thrust::remove_copy_if(select_system(system1,system2), first, last, result, pred);
210 } // end remove_copy_if()
211
212
213 template<typename InputIterator1,
214          typename InputIterator2,
215          typename OutputIterator,
216          typename Predicate>
217   OutputIterator remove_copy_if(InputIterator1 first,
218                                 InputIterator1 last,
219                                 InputIterator2 stencil,
220                                 OutputIterator result,
221                                 Predicate pred)
222 {
223   using thrust::system::detail::generic::select_system;
224
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;
228
229   System1 system1;
230   System2 system2;
231   System3 system3;
232
233   return thrust::remove_copy_if(select_system(system1,system2,system3), first, last, stencil, result, pred);
234 } // end remove_copy_if()
235
236
237 } // end namespace thrust
238