O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

List

The list container is a linked list and is constructed in the same way as a vector and deque. The resizing and empty test is the same as for a vector (or deque), and you also have access to the front and the back of the list using the same operators as the deque.

Where the list is different is in the various splicing operations that it can support. These splicing operations allow you to move elements from one list to another—no elements are created or destroyed, but the lists grow or shrink in order to accommodate the changed data.

The basic use for the splice operator is as follows:

list<char> my_string; // an empty list
list<char> my_other_string ( 10, 'a ' ); // a list of 'a '

splice ( my_string.begin( ), my_other_string );

This code ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required