header

<iterator>

Iterator definitions
An iterator is any object that, pointing to some element in a range of elements (such as an array or a container), has the ability to iterate through the elements of that range using a set of operators (with at least the increment (++) and dereference (*) operators).

The most obvious form of iterator is a pointer: A pointer can point to elements in an array, and can iterate through them using the increment operator (++). But other kinds of iterators are possible. For example, each container type (such as a list) has a specific iterator type designed to iterate through its elements.

Notice that while a pointer is a form of iterator, not all iterators have the same functionality of pointers; Depending on the properties supported by iterators, they are classified into five different categories:

Iterator categories

Iterators are classified into five categories depending on the functionality they implement:


Input and output iterators are the most limited types of iterators: they can perform sequential single-pass input or output operations.

Forward iterators have all the functionality of input iterators and -if they are not constant iterators- also the functionality of output iterators, although they are limited to one direction in which to iterate through a range (forward). All standard containers support at least forward iterator types.

Bidirectional iterators are like forward iterators but can also be iterated through backwards.

Random-access iterators implement all the functionality of bidirectional iterators, and also have the ability to access ranges non-sequentially: distant elements can be accessed directly by applying an offset value to an iterator without iterating through all the elements in between. These iterators have a similar functionality to standard pointers (pointers are iterators of this category).

The properties of each iterator category are:

categorypropertiesvalid expressions
all categoriescopy-constructible, copy-assignable and destructibleX b(a);
b = a;
Can be incremented++a
a++
Random AccessBidirectionalForwardInputSupports equality/inequality comparisonsa == b
a != b
Can be dereferenced as an rvalue*a
a->m
OutputCan be dereferenced as an lvalue
(only for mutable iterator types)
*a = t
*a++ = t
default-constructibleX a;
X()
Multi-pass: neither dereferencing nor incrementing affects dereferenceability{ b=a; *a++; *b; }
Can be decremented--a
a--
*a--
Supports arithmetic operators + and -a + n
n + a
a - n
a - b
Supports inequality comparisons (<, >, <= and >=) between iteratorsa < b
a > b
a <= b
a >= b
Supports compound assignment operations += and -=a += n
a -= n
Supports offset dereference operator ([])a[n]

Where X is an iterator type, a and b are objects of this iterator type, t is an object of the type pointed by the iterator type, and n is an integer value.

For more details, see the references for input iterator, output iterator, forward iterator, bidirectional iterator and random-access iterator.

Functions

Iterator operations:

Iterator generators:

Classes


Predefined iterators


Category tags

<var id="pwjBlLZ"><strike id="pwjBlLZ"></strike></var>
<ins id="pwjBlLZ"></ins>
<ins id="pwjBlLZ"></ins>
<cite id="pwjBlLZ"><dl id="pwjBlLZ"></dl></cite>
<ins id="pwjBlLZ"></ins>
<cite id="pwjBlLZ"></cite><var id="pwjBlLZ"><dl id="pwjBlLZ"></dl></var><ins id="pwjBlLZ"><strike id="pwjBlLZ"><menuitem id="pwjBlLZ"></menuitem></strike></ins>
<menuitem id="pwjBlLZ"><dl id="pwjBlLZ"><progress id="pwjBlLZ"></progress></dl></menuitem><var id="pwjBlLZ"><strike id="pwjBlLZ"></strike></var><ins id="pwjBlLZ"><strike id="pwjBlLZ"><menuitem id="pwjBlLZ"></menuitem></strike></ins>
<var id="pwjBlLZ"><strike id="pwjBlLZ"></strike></var>
<var id="pwjBlLZ"><strike id="pwjBlLZ"></strike></var>
<ins id="pwjBlLZ"><video id="pwjBlLZ"><menuitem id="pwjBlLZ"></menuitem></video></ins>
<ins id="pwjBlLZ"><strike id="pwjBlLZ"></strike></ins>
<cite id="pwjBlLZ"></cite>
<var id="pwjBlLZ"><dl id="pwjBlLZ"><progress id="pwjBlLZ"></progress></dl></var><cite id="pwjBlLZ"><strike id="pwjBlLZ"><thead id="pwjBlLZ"></thead></strike></cite>
<ins id="pwjBlLZ"></ins><var id="pwjBlLZ"><strike id="pwjBlLZ"></strike></var><var id="pwjBlLZ"></var>
  • 8957701587 2018-02-23
  • 3891941586 2018-02-23
  • 6039851585 2018-02-23
  • 2573991584 2018-02-23
  • 7728781583 2018-02-23
  • 3731582 2018-02-23
  • 1007451581 2018-02-22
  • 8908121580 2018-02-22
  • 141161579 2018-02-22
  • 9421578 2018-02-22
  • 2826901577 2018-02-22
  • 3647361576 2018-02-22
  • 5717551575 2018-02-22
  • 523811574 2018-02-22
  • 6439871573 2018-02-22
  • 8109431572 2018-02-22
  • 8757321571 2018-02-22
  • 5265111570 2018-02-22
  • 3351351569 2018-02-22
  • 5109361568 2018-02-22