|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Singly linked list of nodes that store values of type T.
More...
#include <tpl_slist.H>
Classes | |
| class | Iterator |
| Iterator over singly linked nodes. More... | |
Public Types | |
| typedef Snode< T > | Node |
Public Member Functions | |
| Slist ()=default | |
| Default constructor. | |
| void | insert_first (Node *node) |
Insert node right after this sentinel (at the beginning). | |
| Node * | remove_first_ne () noexcept |
| Remove and return the first node without checking emptiness. | |
| Node * | remove_first () |
| Remove the first node of the list. | |
| Node * | get_first () |
| Return a pointer to the first node; throw if the list is empty. | |
| const Node * | get_first () const |
| Return a pointer to the first node (const overload). | |
| Node * | get_first_ne () noexcept |
| Return the first node without checking emptiness. | |
| const Node * | get_first_ne () const noexcept |
| Return the first node without checking emptiness (const overload). | |
Public Member Functions inherited from Aleph::Snode< T > | |
| T & | get_data () |
| Return a modifiable reference to the stored data. | |
| const T & | get_data () const |
| Return a constant reference to the stored data. | |
| Snode ()=default | |
| Default constructor. | |
| Snode (const T &_data) | |
| Constructor that copies the value. | |
| Snode (T &&_data) | |
| Constructor that moves the value. | |
| Snode * | remove_next () |
Remove the node right after this and return it. | |
| Snode *& | get_next () |
Return the next node after this. | |
| const Snode * | get_next () const |
Return the next node after this (const overload). | |
| Snode * | remove_first () |
| Remove and return the first node (for symmetry with list front). | |
| const Snode * | get_first () const |
Return the first node (const alias of get_next). | |
Public Member Functions inherited from Aleph::Slink | |
| Slink () | |
| Default constructor. | |
| void | reset () noexcept |
| Reset the link so it points to itself. | |
| constexpr bool | is_empty () const noexcept |
| Return true if this link is empty (points to itself). | |
| constexpr Slink *& | get_next () noexcept |
| Return the next link. | |
| constexpr const Slink * | get_next () const noexcept |
| Return the next link (const overload). | |
| void | insert_next (Slink *p) |
Insert link p right after this. | |
| Slink * | remove_next () |
Remove the link right after this. | |
Additional Inherited Members | |
Protected Attributes inherited from Aleph::Slink | |
| Slink * | next |
Singly linked list of nodes that store values of type T.
Slist<T> is a node-based list where each element is a Snode<T> storing the payload of type T.
| T | data type held by each node |
Definition at line 101 of file tpl_slist.H.
Definition at line 106 of file tpl_slist.H.
|
default |
Default constructor.
|
inline |
Return a pointer to the first node; throw if the list is empty.
Definition at line 142 of file tpl_slist.H.
References ah_underflow_error_if, Aleph::Snode< T >::get_next(), and Aleph::Slink::is_empty().
Referenced by TEST().
Return a pointer to the first node (const overload).
Definition at line 150 of file tpl_slist.H.
References ah_underflow_error_if, Aleph::Slink::get_next(), and Aleph::Slink::is_empty().
Return the first node without checking emptiness (const overload).
Definition at line 161 of file tpl_slist.H.
References Aleph::Slink::get_next().
|
inlinenoexcept |
Return the first node without checking emptiness.
Definition at line 158 of file tpl_slist.H.
References Aleph::Snode< T >::get_next().
Referenced by Aleph::DynSlist< T >::operator[](), Aleph::Slist< T >::Iterator::reset_first(), and TEST().
Insert node right after this sentinel (at the beginning).
| [in] | node | pointer to the node to insert |
Definition at line 115 of file tpl_slist.H.
References Aleph::Slink::insert_next(), Aleph::Slink::is_empty(), and Aleph::maps().
|
inline |
Remove the first node of the list.
| underflow_error | if the list is empty |
Definition at line 134 of file tpl_slist.H.
References ah_underflow_error_if, Aleph::Slink::is_empty(), and Aleph::Snode< T >::remove_next().
|
inlinenoexcept |
Remove and return the first node without checking emptiness.
Definition at line 124 of file tpl_slist.H.
References Aleph::Snode< T >::remove_next().
Referenced by Aleph::DynSlist< T >::clear(), and TEST().