OSDN Git Service

CUDA
[eos/hostdependX86LINUX64.git] / util / X86LINUX64 / cuda-6.5 / include / thrust / detail / count.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 count.inl
19  *  \brief Inline file for count.h.
20  */
21
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>
28
29 namespace thrust
30 {
31
32
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)
36 {
37   using thrust::system::detail::generic::count;
38   return count(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, value);
39 } // end count()
40
41
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)
45 {
46   using thrust::system::detail::generic::count_if;
47   return count_if(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last, pred);
48 } // end count_if()
49
50
51 template <typename InputIterator, typename EqualityComparable>
52 typename thrust::iterator_traits<InputIterator>::difference_type
53 count(InputIterator first, InputIterator last, const EqualityComparable& value)
54 {
55   using thrust::system::detail::generic::select_system;
56
57   typedef typename thrust::iterator_system<InputIterator>::type System;
58
59   System system;
60
61   return thrust::count(select_system(system), first, last, value);
62 } // end count()
63
64
65 template <typename InputIterator, typename Predicate>
66 typename thrust::iterator_traits<InputIterator>::difference_type
67 count_if(InputIterator first, InputIterator last, Predicate pred)
68 {
69   using thrust::system::detail::generic::select_system;
70
71   typedef typename thrust::iterator_system<InputIterator>::type System;
72
73   System system;
74
75   return thrust::count_if(select_system(system), first, last, pred);
76 } // end count_if()
77
78
79 } // end namespace thrust
80