Forward Lists

A forward list is the primitive form of the list structure we studied in the previous lesson. Nevertheless, forward lists are still useful.

We'll cover the following...
widget

std::forward_list is a singly linked list, which needs the header <forward_list>. std::forward_list has a drastically reduced interface and is optimized for minimal memory requirements.

std::forward_list has a lot in common with std::list:

  • It supports no random access.
  • The access of an arbitrary element is slow because in the worst case you have to iterate forward through the whole list.
  • To add or remove an element is fast, if the iterator points to the right place.
...