|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once |
|
|
|
|
|
#include <thrust/detail/config.h> |
|
|
|
|
|
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) |
|
|
# pragma GCC system_header |
|
|
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) |
|
|
# pragma clang system_header |
|
|
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) |
|
|
# pragma system_header |
|
|
#endif |
|
|
#include <thrust/detail/function.h> |
|
|
#include <thrust/system/detail/sequential/execution_policy.h> |
|
|
|
|
|
THRUST_NAMESPACE_BEGIN |
|
|
namespace system |
|
|
{ |
|
|
namespace detail |
|
|
{ |
|
|
namespace sequential |
|
|
{ |
|
|
|
|
|
|
|
|
__thrust_exec_check_disable__ |
|
|
template<typename DerivedPolicy, |
|
|
typename ForwardIterator, |
|
|
typename Predicate> |
|
|
__host__ __device__ |
|
|
ForwardIterator remove_if(sequential::execution_policy<DerivedPolicy> &, |
|
|
ForwardIterator first, |
|
|
ForwardIterator last, |
|
|
Predicate pred) |
|
|
{ |
|
|
|
|
|
thrust::detail::wrapped_function< |
|
|
Predicate, |
|
|
bool |
|
|
> wrapped_pred(pred); |
|
|
|
|
|
|
|
|
while(first != last && !wrapped_pred(*first)) |
|
|
++first; |
|
|
|
|
|
if(first == last) |
|
|
return first; |
|
|
|
|
|
|
|
|
ForwardIterator result = first; |
|
|
|
|
|
++first; |
|
|
|
|
|
while(first != last) |
|
|
{ |
|
|
if(!wrapped_pred(*first)) |
|
|
{ |
|
|
*result = *first; |
|
|
++result; |
|
|
} |
|
|
++first; |
|
|
} |
|
|
|
|
|
return result; |
|
|
} |
|
|
|
|
|
|
|
|
__thrust_exec_check_disable__ |
|
|
template<typename DerivedPolicy, |
|
|
typename ForwardIterator, |
|
|
typename InputIterator, |
|
|
typename Predicate> |
|
|
__host__ __device__ |
|
|
ForwardIterator remove_if(sequential::execution_policy<DerivedPolicy> &, |
|
|
ForwardIterator first, |
|
|
ForwardIterator last, |
|
|
InputIterator stencil, |
|
|
Predicate pred) |
|
|
{ |
|
|
|
|
|
thrust::detail::wrapped_function< |
|
|
Predicate, |
|
|
bool |
|
|
> wrapped_pred(pred); |
|
|
|
|
|
|
|
|
while(first != last && !wrapped_pred(*stencil)) |
|
|
{ |
|
|
++first; |
|
|
++stencil; |
|
|
} |
|
|
|
|
|
if(first == last) |
|
|
return first; |
|
|
|
|
|
|
|
|
ForwardIterator result = first; |
|
|
|
|
|
++first; |
|
|
++stencil; |
|
|
|
|
|
while(first != last) |
|
|
{ |
|
|
if(!wrapped_pred(*stencil)) |
|
|
{ |
|
|
*result = *first; |
|
|
++result; |
|
|
} |
|
|
++first; |
|
|
++stencil; |
|
|
} |
|
|
|
|
|
return result; |
|
|
} |
|
|
|
|
|
|
|
|
__thrust_exec_check_disable__ |
|
|
template<typename DerivedPolicy, |
|
|
typename InputIterator, |
|
|
typename OutputIterator, |
|
|
typename Predicate> |
|
|
__host__ __device__ |
|
|
OutputIterator remove_copy_if(sequential::execution_policy<DerivedPolicy> &, |
|
|
InputIterator first, |
|
|
InputIterator last, |
|
|
OutputIterator result, |
|
|
Predicate pred) |
|
|
{ |
|
|
|
|
|
thrust::detail::wrapped_function< |
|
|
Predicate, |
|
|
bool |
|
|
> wrapped_pred(pred); |
|
|
|
|
|
while (first != last) |
|
|
{ |
|
|
if (!wrapped_pred(*first)) |
|
|
{ |
|
|
*result = *first; |
|
|
++result; |
|
|
} |
|
|
|
|
|
++first; |
|
|
} |
|
|
|
|
|
return result; |
|
|
} |
|
|
|
|
|
|
|
|
__thrust_exec_check_disable__ |
|
|
template<typename DerivedPolicy, |
|
|
typename InputIterator1, |
|
|
typename InputIterator2, |
|
|
typename OutputIterator, |
|
|
typename Predicate> |
|
|
__host__ __device__ |
|
|
OutputIterator remove_copy_if(sequential::execution_policy<DerivedPolicy> &, |
|
|
InputIterator1 first, |
|
|
InputIterator1 last, |
|
|
InputIterator2 stencil, |
|
|
OutputIterator result, |
|
|
Predicate pred) |
|
|
{ |
|
|
|
|
|
thrust::detail::wrapped_function< |
|
|
Predicate, |
|
|
bool |
|
|
> wrapped_pred(pred); |
|
|
|
|
|
while (first != last) |
|
|
{ |
|
|
if (!wrapped_pred(*stencil)) |
|
|
{ |
|
|
*result = *first; |
|
|
++result; |
|
|
} |
|
|
|
|
|
++first; |
|
|
++stencil; |
|
|
} |
|
|
|
|
|
return result; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
THRUST_NAMESPACE_END |
|
|
|
|
|
|