List

As the name suggests, a list object is implemented by a doubly linked list in which each item has a link to the next item and the previous one. This means that it is quick to insert items (as the example in Chapter 4, Working with Memory, Arrays, and Pointers, showed with a singly linked list), but since, in a linked list, an item only has access to the items in front and behind it, there is no random access with the [] indexoperator. The class allows you to provide values through the constructor, or you can use member methods. For example, the assign method allows you fill the container in one action using an initializer list, or, with iterators, to a range in another container. You can also insert a single item using the push_back ...

Get Beginning C++ Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.