container adaptors c++
In addition to the fundamental container classes, the C++ standard library provides special predefined container adapters that meet special needs. These are implemented by using the fundamental containers classes. The predefined container adapters are as follows:
- Stacks : The name says it all. A stack is a container that manages its elements by the LIFO (lastin- first-out) policy.
- Queues : A queue is a container that manages its elements by the FIFO (first-in-first-out) policy. That is, it is an ordinary buffer.
- Priority Queues : A priority queue is a container in which the elements may have different priorities. The priority is based on a sorting criterion that the programmer may provide (by default, operator < is used). A priority queue is, in effect, a buffer in which the next element is always the element that has the highest priority inside the queue. If more than one element has the highest priority, the order of these elements is undefined.
Container adapters are historically part of the STL. However, from programmer's view point, they are just special containers that use the general framework of the containers, iterators, and algorithms provided by the STL.