In each of the following descriptions, start is an iterator pointing to the beginning of a sequence (usually container.begin()), and stop is an iterator pointing to the end of a sequence (usually container.end()). Most of these require that the header file algorithm be included (accumulate() requires numeric instead). This is not an exhaustive listing of the C++ standard algorithms library. For an exhaustive list, see the latest on the ANSI C++ standard at Cygnus.com.
| algorithm | Description |
|---|---|
| accumulate(start, stop, value); | Return the sum of the values in the sequence plus value |
| find(start, stop, value); | Return an iterator to value in the sequence, or stop if it is not present |
| count(start, stop, value); | Return the number of times value occurs in the sequence |
| fill(start, stop, value); | Assign value to every element of the sequence |
| iota(start, stop, value); | Fill the sequence with monotonically ascending values, beginning with value |
| replace(start, stop, old, new); | Replace each occurrence of old in the sequence with new |
| for_each(start, stop, F); | Apply function F to each value in the sequence |
| max_element(start, stop); | Return an iterator to the maximum value in the sequence |
| min_element(start, stop); | Return an iterator to the minimum value in the sequence |
| reverse(start, stop); | Reverse the order of the values in the sequence |
| random_shuffle(start, stop); | Shuffle the values in the sequence randomly |
| sort(start, stop); | Arrange the sequence's values in ascending order |
| binary_search(start, stop, value); | Return true if value is in the sorted sequence, or false if it is not present |
| lower_bound(start, stop, value); | Return an iterator to the first position at which value can be inserted, such that the sequence remains sorted. |
| upper_bound(start, stop, value); | Return an iterator to the last position at which value can be inserted, such that the sequence remains sorted. |
| unique(start, stop); | In the sequence, replace any consecutive occurrences of the same value with one instance of that value |
| next_permutation(start, stop); | Shuffle the sequence to its next permutation and return true (If there is none, return false) |
| prev_permutation(start, stop); | Shuffle the sequence to its previous permutation and return true (If there is none, return false) |