<algorithm>
The <algorithm>
header declares the generic algorithm function templates
for operating on iterators and other objects. Refer to Chapter 10 for more information about
using and writing generic algorithms and about the iterators they use.
See Chapter 8 for a discussion of
iterator traits.
Note
If you are at all confused by the removal algorithms (such as
pop_heap
, remove
, and unique
), be sure to read Chapter 10 first.
This section uses a number of abbreviations and conventions. First, each algorithm is described using plain English. Then, a more mathematical description of the algorithm, which tends to be harder to read, is given in a “Technical Notes” section.
The names of the template parameters tell you which category of iterator is expected. The iterator category is the minimal functionality needed, so you can, for example, use a random access iterator where at least a forward iterator is needed. (See Chapter 10 for more information on iterators and iterator categories.) To keep the syntax summaries short and readable, the iterator categories are abbreviated, as shown in Table 13-1.
Parameter name | Iterator category |
| Bidirectional iterator |
| Forward iterator |
| Input iterator |
| Output iterator |
| Random access iterator |
Other template parameter names are chosen to be self-explanatory.
For example, any name that ends in Predicate
is a function that returns a Boolean result (which can be ...
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.