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 count.h.
22 #include <thrust/detail/config.h>
23 #include <thrust/count.h>
24 #include <thrust/iterator/iterator_traits.h>
25 #include <thrust/system/detail/generic/select_system.h>
26 #include <thrust/system/detail/generic/count.h>
27 #include <thrust/system/detail/adl/count.h>
33 template<typename DerivedPolicy, typename InputIterator, typename EqualityComparable>
34 typename thrust::iterator_traits<InputIterator>::difference_type
35 count(const thrust::detail::execution_policy_base<DerivedPolicy> &exec, InputIterator first, InputIterator last, const EqualityComparable& value)
37 using thrust::system::detail::generic::count;
38 return count(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, value);
42 template<typename DerivedPolicy, typename InputIterator, typename Predicate>
43 typename thrust::iterator_traits<InputIterator>::difference_type
44 count_if(const thrust::detail::execution_policy_base<DerivedPolicy> &exec, InputIterator first, InputIterator last, Predicate pred)
46 using thrust::system::detail::generic::count_if;
47 return count_if(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, pred);
51 template <typename InputIterator, typename EqualityComparable>
52 typename thrust::iterator_traits<InputIterator>::difference_type
53 count(InputIterator first, InputIterator last, const EqualityComparable& value)
55 using thrust::system::detail::generic::select_system;
57 typedef typename thrust::iterator_system<InputIterator>::type System;
61 return thrust::count(select_system(system), first, last, value);
65 template <typename InputIterator, typename Predicate>
66 typename thrust::iterator_traits<InputIterator>::difference_type
67 count_if(InputIterator first, InputIterator last, Predicate pred)
69 using thrust::system::detail::generic::select_system;
71 typedef typename thrust::iterator_system<InputIterator>::type System;
75 return thrust::count_if(select_system(system), first, last, pred);
79 } // end namespace thrust