Top of document
©Copyright 1999 Rogue Wave Software

Containers

Summary

A standard template library (STL) collection.

Contents

Description

Within the standard template library, collection classes are often described as containers. A container stores a collection of other objects and provides certain basic functionality that supports the use of generic algorithms. Containers come in two basic flavors: sequences, and associative containers. They are further distinguished by the type of iterator they support.

A sequence supports a linear arrangement of single elements. vector, list, deque, bitset, and string fall into this category. Associative containers map values onto keys, which provides efficient retrieval of the values based on the keys. The STL provides the map, multimap, set and multiset associative containers. map and multimap store the value and the key separately and allow for fast retrieval of the value, based upon fast retrieval of the key. set and multiset store only keys allowing fast retrieval of the key itself.

Container Requirements

Containers within the STL must meet the following requirements. Sequences and associative containers must also meet their own separate sets of requirements. The requirements for containers are:

Reversible Containers

A container may be reversible. Essentially, a reversible container provides a reverse iterator that allows traversal of the collection in a direction opposite that of the default iterator. A reversible container must meet the following requirements in addition to those listed above:

Sequences

In addition to the requirements for containers, the following requirements hold for sequences:

Associative Containers

In addition to the requirements for a container, the following requirements hold for associative containers:

See Also

bitset, deque, list, map, multimap, multiset, priority_queue, queue, set, stack, vector


Top of document