Iterator

Iterator in #202202241717 could be used to iterate through 202202241719 or structures. They do not own the object that they refer.

There are 5 categories of them which could be verified by 202204181611# :

  • output iterator
  • input iterator
  • forward iterator
  • bidirectional iterator, where the iterator could move forward and backward
  • random access iterator

Multi-pass and Single-pass

The Interators can be grouped into 2 groups based on their behaviour: Multi-pass Iterator and Single-pass Iterator.

Multi-pass Iterator could be iterated more than one time and its content will not be altered when wrote or read (using dereference). The example of such are forward iterator, bidirectional iterator and random access iterator. Most sequence 202202241719 support this.

Single-pass Iterator’s content or value will be changed upon write, read or iterated. The example of such are output iterator and input iterator. This is usually seen when using with file streams, socket or raw devices.

Iteration

The Iteration is done by using a pair of iterators: first and last. first refer to the first element included in the sequence. last refer to the non-dereferenceable position excluded from the sequence.

Links to this page
#cpp #stl #sorting