The C++ standard library type list
represents a doubly-linked list, and forward_list
is a singly-linked list. Fortunately, the implementations of both of these lists are pretty much what you expect.
Inside STL: The lists
By Raymond Chen
From the article:
Let’s start with the simpler
forward_
.list template<typename T> struct forward_list { forward_list_node<T>* head; }; template<typename T> struct forward_list_node { forward_list_node<T>* next; T value; };The
forward_
itself is a pointer to the first element of the list, orlist nullptr
if the list is empty. Each subsequent element contains a pointer to the next element, ornullptr
if there is no next element.
Add a Comment
Comments are closed.