count.hppGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef ADOBE_ALGORITHM_COUNT_HPP
00010 #define ADOBE_ALGORITHM_COUNT_HPP
00011
00012 #include <adobe/config.hpp>
00013
00014 #include <boost/range/begin.hpp>
00015 #include <boost/range/difference_type.hpp>
00016 #include <boost/range/end.hpp>
00017 #include <boost/bind.hpp>
00018
00019 #include <algorithm>
00020
00021
00022
00023 namespace adobe {
00024
00025
00034
00040 template <class InputRange, class T>
00041 inline typename boost::range_difference<InputRange>::type count(InputRange& range, T& value)
00042 {
00043 return std::count(boost::begin(range), boost::end(range), value);
00044 }
00045
00051 template <class InputRange, class T>
00052 inline typename boost::range_difference<InputRange>::type
00053 count(const InputRange& range, T& value)
00054 {
00055 return std::count(boost::begin(range), boost::end(range), value);
00056 }
00057
00063 template <class InputIterator, class Predicate>
00064 inline typename std::iterator_traits<InputIterator>::difference_type
00065 count_if(InputIterator first, InputIterator last, Predicate pred)
00066 {
00067 return std::count_if(first, last, boost::bind(pred, _1));
00068 }
00069
00075 template <class InputRange, class Predicate>
00076 inline typename boost::range_difference<InputRange>::type
00077 count_if(InputRange& range, Predicate pred)
00078 {
00079 return adobe::count_if(boost::begin(range), boost::end(range), pred);
00080 }
00081
00087 template <class InputRange, class Predicate>
00088 inline typename boost::range_difference<InputRange>::type
00089 count_if(const InputRange& range, Predicate pred)
00090 {
00091 return adobe::count_if(boost::begin(range), boost::end(range), pred);
00092 }
00093
00094
00095
00096 }
00097
00098
00099
00100 #endif
00101
00102
|