The Standard Template
Library
G
C++ is endowed with the standard template library (STL), which offers a
variety of utility functions and data structures generalized as templates and
coined containers.
A comprehensive reference manual of the STL can be found at the Inter-
net sites:
http://cppreference.com
http://www.josuttis.com/libbook/idx.html
The contents of STL can be broadly classified into the following categories:
- Algorithmscontaining various subroutines and utility functions
- Sequence containers(vectors, lists) holding sequences of data elements
- Associative containers(maps and multimaps) containing key/value pairs
that provide access to values by way of keys - Ordered sets(sets and multisets) storing elements in an orderly fashion
- Container adapters(stacks, queues, and priority queues) used to enforce
access rules - Specialized containers(bitsets, strings, valarrays) offering limited yet ef-
ficient implementations for specific data types
A vectorcontains contiguous elements stored in an array. Accessing
members or appending elements requires constant time, as in RAM; locating a
specific element or inserting elements requires linear time.
Astringis similar to avector
utility functions.
Adouble-ended queueoffers fast insertion and deletion at the beginning
and end of a vector.