Categories
Their capabilities can categorise iterator. C++ has forward, bidirectional and random access iterators. With the forward iterator, you can iterate the container forward, with the bidirectional iterator, in both directions. With the random access iterator, you can directly access an arbitrary element. In particular, this means for the last one, that you can use iterator arithmetic and ordering comparisons (e.g.: <
). The category of an iterator depends on the type of the container used.
In the table below is a representation of containers and their iterator categories. The bidirectional iterator includes the forward iterator functionalities, and the random access iterator includes the forward and the bidirectional iterator functionalities. It
and It2
are iterators, n
is a natural number.
Iterator category | Properties | Container |
---|---|---|
Forward iterator | ++It, It++, *It |
unordered... |