Lesson 18. STL list and forward_list

The Standard Template Library (STL) supplies the programmer with a doubly linked list in the form of template class std::list. The main advantage of a linked list is in fast and constant time insertion and removal of elements. Starting C++11, you can also use a singly linked list in the form of std::forward_list that can be traversed only in one direction.

In this lesson, you learn

• How to instantiate the list and forward_list

• Using the STL list classes, including insertion and removal

• How to reverse and sort elements

The Characteristics of a std::list

A linked list is a collection of nodes in which each node, in addition to containing a value or object of interest, also points to the next node; that ...

Get Sams Teach Yourself C++ in One Hour a Day, Seventh Edition 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.