The sequence containers represent linear data structures (i.e., all of their elements are conceptually “lined up in a row”), such as array
s, vector
s and linked lists. Associative containers are nonlinear data structures that typically can locate elements stored in the containers quickly. Such containers can store sets of values or key–value pairs. As of C++11, the keys in associative containers are immutable (they cannot be modified). The sequence containers and associative containers are collectively referred to as the first-class containers. Stacks and queues are typically constrained versions of sequence containers. For this reason, the Standard Library implements class templates stack
, queue
and priority_queue
as container adapters that enable a program to view a sequence container in a constrained manner. Class string
supports the same functionality as a sequence container, but stores only character data.