Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) Iterator

 

Iterators allow a uniform way to travel through all STL containers.

 

 

 

 

 

Example

 

 

 

 

 

 

Advice

 

 

 

 

 

 

References

 

  1. Herb Sutter. Exceptional C++ style. 2005. ISBN: 0-201-76042-8. Item 1 guideline: 'Prefer reusing algorithms, particularly standard algorithms (e.g., for_each), instead of crafting your own loops'.
  2. Herb Sutter. Exceptional C++ style. 2005. ISBN: 0-201-76042-8. Item 1 guideline: 'Use const_iterator when you are not modifying the contents of a container'.
  3. Herb Sutter. Exceptional C++ style. 2005. ISBN: 0-201-76042-8. Item 1 guideline: 'Prefer comparing iterators with !=, not <'.
  4. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 31.6. Advice. page 924: '[16] Use const iterators where you don't need to modify the elements of a container'
  5. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 31.6. Advice. page 924: '[17] Use auto to avoid verbosity and typos when you use iterators'
  6. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 31.6. Advice. page 924: '[21] Don't use iterators into a resized vector or deque'

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict