Lecture overview -- Keyboard shortcut: 'u'  Previous page: Different classifications of iterators -- Keyboard shortcut: 'p'  Next page: Insert iterators -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 5 - Page 20 : 39
Notes about C++
Templates and The Standard Library
Categories of iterators

Tabular overview of the five catetories at the top of page 551

The classification list operations that can be implemented efficiently - O(1)

  • The C++ Programming Language: Page 550
 

 

  • All iterators

    • ++

  • Output iterator p

    • Can write into the container with *p = x

    • Cannot read the current element by x = *p

  • Input iterator p

    • Can read the current element by x = *p

    • Cannot write to current element by *p = x

    • Other operators: ==, !=

  • Forward

    • As read and write

    • Other operators: ==, !=

  • Bidirectional

    • -- applies

    • Else like forward iterators

  • Random-access

    • Can add and subtract integers to/from iterators

    • Can read and write

    • Can compare iterators with <, <=, >, and >=

    • Other operators: ==, !=

The categories are not represented by inheritance, but they appear in iterator tags types (page 554) - used for convenient functions overloding

The distance between two iterators can be calculated for all iterators, appart from output iterators, simply by advancing the first until it meets the other