Skip to main content

Containers

  • Chapter
  • First Online:
Book cover C++ Standard Library Quick Reference
  • 3296 Accesses

Abstract

The C++ Standard Library provides a selection of different data structures that you can use to store data. Containers work in tandem with algorithms, described in Chapter 4. Containers and algorithms are designed in such a way that they do not need to know about each other. The interaction between them is accomplished with iterators. All containers provide iterators, and algorithms only need iterators to be able to perform their work.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 19.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    The way operator< is defined for Person in the Introduction chapter causes the VIP and non-VIP persons in the priority_queue to be in reverse alphabetical order: people with an alphabetically higher name get a higher priority.

  2. 2.

    Technically, you could easily implement a hash map without buckets: for example, using so-called open addressing. The way the standard unordered containers are defined, though, strongly suggests the use of a separate chaining method, which is therefore what we describe here.

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2016 Peter Van Weert and Marc Gregoire

About this chapter

Cite this chapter

Van Weert, P., Gregoire, M. (2016). Containers. In: C++ Standard Library Quick Reference. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-1876-1_3

Download citation

Publish with us

Policies and ethics