stlab.adobe.com Adobe Systems Incorporated
count.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2005-2007 Adobe Systems Incorporated
3  Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
4  or a copy at http://stlab.adobe.com/licenses.html)
5 */
6 
7 /*************************************************************************************************/
8 
9 #ifndef ADOBE_ALGORITHM_COUNT_HPP
10 #define ADOBE_ALGORITHM_COUNT_HPP
11 
12 #include <adobe/config.hpp>
13 
14 #include <boost/range/begin.hpp>
15 #include <boost/range/difference_type.hpp>
16 #include <boost/range/end.hpp>
17 #include <boost/bind.hpp>
18 
19 #include <algorithm>
20 
21 /*************************************************************************************************/
22 
23 namespace adobe {
24 
25 /*************************************************************************************************/
34 /*************************************************************************************************/
40 template <class InputRange, class T>
41 inline typename boost::range_difference<InputRange>::type count(InputRange& range, T& value)
42 {
43  return std::count(boost::begin(range), boost::end(range), value);
44 }
45 
51 template <class InputRange, class T>
52 inline typename boost::range_difference<InputRange>::type
53 count(const InputRange& range, T& value)
54 {
55  return std::count(boost::begin(range), boost::end(range), value);
56 }
57 
63 template <class InputIterator, class Predicate>
64 inline typename std::iterator_traits<InputIterator>::difference_type
65 count_if(InputIterator first, InputIterator last, Predicate pred)
66 {
67  return std::count_if(first, last, boost::bind(pred, _1));
68 }
69 
75 template <class InputRange, class Predicate>
76 inline typename boost::range_difference<InputRange>::type
77 count_if(InputRange& range, Predicate pred)
78 {
79  return adobe::count_if(boost::begin(range), boost::end(range), pred);
80 }
81 
87 template <class InputRange, class Predicate>
88 inline typename boost::range_difference<InputRange>::type
89 count_if(const InputRange& range, Predicate pred)
90 {
91  return adobe::count_if(boost::begin(range), boost::end(range), pred);
92 }
93 
94 /*************************************************************************************************/
95 
96 } // namespace adobe
97 
98 /*************************************************************************************************/
99 
100 #endif
101 
102 /*************************************************************************************************/
boost::range_difference< InputRange >::type count_if(const InputRange &range, Predicate pred)
count implementation
Definition: count.hpp:89
boost::range_difference< InputRange >::type count(InputRange &range, T &value)
count implementation
Definition: count.hpp:41
boost::range_difference< InputRange >::type count(const InputRange &range, T &value)
count implementation
Definition: count.hpp:53
std::iterator_traits< InputIterator >::difference_type count_if(InputIterator first, InputIterator last, Predicate pred)
count implementation
Definition: count.hpp:65

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google