The STL achieves its results through the use of templates. This approach provides compile-time polymorphism that is often more efficient than traditional run-time polymorphism.
Modern C++ compilers are tuned to minimize any abstraction penalty arising from heavy use of the STL.
STL (Standard Template Library) Algorithms Container Classes A library of class and function templates based on work in generic programming done by Alex Stepanov and Meng Lee of the Hewlett Packard Laboratories in the early 1990s. vector sort() begin() end() Iterates
The STL contains sequence containers and associative containers .
The standard sequence containers include vector , deque , and list .
The standard associative containers are set , multiset , map , and multimap .
There are also container adaptors queue , priority_queue , and stack , that are containers with specific interface, using other containers as implementation.
STL's Containers In 1994, STL was adopted as a standard part of C++. There are some containers in STL: Kind of Container STL Containers Sequential: deque , list , vector Associative: map , multimap , multiset , set Adapters: priority_queue , queue , stack Non-STL: bitset , valarray , string
Store elements in linear sequence. Ex – array , vector , list , deque.
Used to automatically arrange stored data in a specific order. Uses trees. Ex – set , multiset , map , multimap .
Container Adapters / Derived Containers
Special purpose containers created from normal containers
Sequence Containers Ex. vector<int> v1; vector<int>iterator iter; Random Quick random access, slow insertion/deletion in middle, size can not be changed at runtime array Iterator Description Container Random Double ended queue, direct access, slow insert/delete in middle, fast at beg/ end deque Bidir. Doubly link list, fast insert/delete anywhere, slow random access list Random Dynamic array, quick random access, slow insertion/deletion in middle, fast at back vector
Derived Containers/Container Adapters Ex. stack <deque<int> > s1; Iterator Description Container None Element of highest priority popped. Create from vector or dequeue Priority -queue None FIFO. Create from list or dequeue Queue None LIFO. Create from vector, list or dequeue Stack
A large number of algorithms to perform operations such as searching and sorting are provided in the STL, each implemented to require a certain level of iterator (and therefore will work on any container that provides an interface by iterators).