15. Standard Library Containers and Iterators

They are the books, the arts, the academes, That show, contain, and nourish all the world.

—William Shakespeare

Journey over all the universe in a map.

—Miguel de Cervantes

Objectives

In this chapter you’ll:

• Introduce the Standard Library containers, iterators and algorithms.

• Use the vector, list and deque sequence containers.

• Use the set, multiset, map and multimap associative containers.

• Use the stack, queue and priority_queue container adapters.

• Use iterators to access container elements.

• Use the copy algorithm and ostream_iterators to output a container.

• Use the bitset “near container” to implement the Sieve of Eratosthenes for determining prime numbers.

Get C++ How to Program, Ninth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.