The Standard C++ Library provides ten alternative forms of containers and three container adaptors. In this chapter we briefly identify these forms, consider their characteristics, and discuss how you might go about selecting which form to use in solving a particular problem. Subsequent chapters then go over each of the different forms in more detail.
Table 6 lists the container types provided by the Standard C++ Library, and describes the most significant characteristic of each. Table 7 does the same for the container adaptors.
Name | Characteristic |
vector |
Random access to elements, efficient insertion at end |
vector<bool> |
Specialization of vector optimized for bool |
list |
Efficient insertion and removal throughout |
deque |
Random access, efficient insertion at front or back |
set |
Elements maintained in order, efficient test for inclusion, insertion, and removal |
multiset |
Set with repeated copies |
bitset |
Bit container templated on size rather than contained type |
map |
Access to values via keys, efficient insertion and removal |
multimap |
Map permitting duplicate keys |
string |
Character container enhanced for string operations |
Name | Characteristic |
---|---|
stack |
Insertions and removals only from top |
queue |
Insertions at back, removals from front |
priority queue |
Efficient access and removal of largest values |
©Copyright 1998, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.