Container adapters
Arrays, lists, trees, and hash tables are not the only way to store and access data, as there are also stacks, queues, and so on. Similar, more sophisticated structures, however, can be implemented using the more primitive ones, and the STL does that with the following ones in the form of container adapters: std::stack, std::queue, and std::priority_queue.
The cool thing is that whenever we need such a data structure, we can just pick such an adapter. Then, when we realize that they do not work out well regarding their performance, we can just change a template parameter in order to let the adapter use a different container implementation, and that's it. In practice, this means, for example, that we can switch the implementation ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access