Varieties of iterators – HP Integrity NonStop H-Series User Manual
Page 26
![background image](/manuals/396950/26/background.png)
Click on the banner to return to the user guide home page.
©Copyright 1996 Rogue Wave Software
Varieties of Iterators
There are five basic forms of iterators used in the standard library:
input iterator
read only, forward moving
output iterator
write only, forward moving
forward iterator
both read and write, forward moving
bidirectional iterator
read and write, forward and backward moving
random access iterator read and write, random access
Iterator categories are hierarchical. Forward iterators can be used wherever input or output iterators
are required, bidirectional iterators can be used in place of forward iterators, and random access
iterators can be used in situations requiring bidirectionality.
A second characteristic of iterators is whether or not they can be used to modify the values held by
their associated container. A constant iterator is one that can be used for access only, and cannot be
used for modification. Output iterators are never constant, and input iterators always are. Other
iterators may or may not be constant, depending upon how they are created. There are both constant
and non-constant bidirectional iterators, both constant and non-constant random access iterators, and
so on.
The following table summarizes specific ways that various categories of iterators are generated by the
containers in the standard library.
Iterator Form
Produced By
input iterator
istream_iterator
output iterator
ostream_iterator
inserter
front_inserter
back_inserter
bidirectional iterator
list
set
and
multiset
map
and
multimap