Standard C++ Library Class Reference

Click on the banner to return to the Class Reference home page.
©Copyright 1996 Rogue Wave Software
count, count_if
Algorithm
Summary
Count the number of elements in a container that satisfy a given condition.
Contents
Synopsis
Description
Complexity
Example
Warnings
Synopsis
#include <algorithm>
template <class InputIterator, class T, class Size>
void count(InputIterator first, InputIterator last,
const T& value, Size& n);
template <class InputIterator, class Predicate, class Size>
void count_if(InputIterator first, InputIterator last,
Predicate pred, Size& n);
Description
The count algorithm compares value to elements in the sequence defined by iterators first and
last, and increments a counting value n each time it finds a match. i.e., count adds to n the
number of iterators i in the range [first, last) for which the following condition holds: