Adobe Source Libraries 1.49.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
count.hpp
Go to the documentation of this file.
1/*
2 Copyright 2013 Adobe
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5*/
6/**************************************************************************************************/
7
8#ifndef ADOBE_ALGORITHM_COUNT_HPP
9#define ADOBE_ALGORITHM_COUNT_HPP
10
11#include <adobe/config.hpp>
12
13#include <boost/range/begin.hpp>
14#include <boost/range/difference_type.hpp>
15#include <boost/range/end.hpp>
16
17#include <algorithm>
18#include <functional>
19
20/**************************************************************************************************/
21
22namespace adobe {
23
24/**************************************************************************************************/
33/**************************************************************************************************/
39template <class InputRange, class T>
40inline typename boost::range_difference<InputRange>::type count(InputRange& range, T& value) {
41 return std::count(boost::begin(range), boost::end(range), value);
42}
43
49template <class InputRange, class T>
50inline typename boost::range_difference<InputRange>::type count(const InputRange& range, T& value) {
51 return std::count(boost::begin(range), boost::end(range), value);
52}
53
59template <class InputIterator, class Predicate>
60inline typename std::iterator_traits<InputIterator>::difference_type
61count_if(InputIterator first, InputIterator last, Predicate pred) {
62 return std::count_if(first, last, std::bind(pred, std::placeholders::_1));
63}
64
70template <class InputRange, class Predicate>
71inline typename boost::range_difference<InputRange>::type count_if(InputRange& range,
72 Predicate pred) {
73 return adobe::count_if(boost::begin(range), boost::end(range), pred);
74}
75
81template <class InputRange, class Predicate>
82inline typename boost::range_difference<InputRange>::type count_if(const InputRange& range,
83 Predicate pred) {
84 return adobe::count_if(boost::begin(range), boost::end(range), pred);
85}
86
87/**************************************************************************************************/
88
89} // namespace adobe
90
91/**************************************************************************************************/
92
93#endif
94
95/**************************************************************************************************/
boost::range_difference< InputRange >::type count(InputRange &range, T &value)
count implementation
Definition count.hpp:40
std::iterator_traits< InputIterator >::difference_type count_if(InputIterator first, InputIterator last, Predicate pred)
count implementation
Definition count.hpp:61