Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Slist< T > Class Template Reference

Singly linked list of nodes that store values of type T. More...

#include <tpl_slist.H>

Inheritance diagram for Aleph::Slist< T >:
[legend]
Collaboration diagram for Aleph::Slist< T >:
[legend]

Classes

class  Iterator
 Iterator over singly linked nodes. More...
 

Public Types

typedef Snode< TNode
 

Public Member Functions

 Slist ()=default
 Default constructor.
 
void insert_first (Node *node)
 Insert node right after this sentinel (at the beginning).
 
Noderemove_first_ne () noexcept
 Remove and return the first node without checking emptiness.
 
Noderemove_first ()
 Remove the first node of the list.
 
Nodeget_first ()
 Return a pointer to the first node; throw if the list is empty.
 
const Nodeget_first () const
 Return a pointer to the first node (const overload).
 
Nodeget_first_ne () noexcept
 Return the first node without checking emptiness.
 
const Nodeget_first_ne () const noexcept
 Return the first node without checking emptiness (const overload).
 
- Public Member Functions inherited from Aleph::Snode< T >
Tget_data ()
 Return a modifiable reference to the stored data.
 
const Tget_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.
 
Snoderemove_next ()
 Remove the node right after this and return it.
 
Snode *& get_next ()
 Return the next node after this.
 
const Snodeget_next () const
 Return the next node after this (const overload).
 
Snoderemove_first ()
 Remove and return the first node (for symmetry with list front).
 
const Snodeget_first () const
 Return the first node (const alias of get_next).
 

Additional Inherited Members

Detailed Description

template<typename T>
class Aleph::Slist< T >

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.

Template Parameters
Tdata type held by each node

Definition at line 101 of file tpl_slist.H.

Member Typedef Documentation

◆ Node

Definition at line 106 of file tpl_slist.H.

Constructor & Destructor Documentation

◆ Slist()

template<typename T >
Aleph::Slist< T >::Slist ( )
default

Default constructor.

Member Function Documentation

◆ get_first() [1/2]

template<typename T >
Node * Aleph::Slist< T >::get_first ( )
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().

◆ get_first() [2/2]

template<typename T >
const Node * Aleph::Slist< T >::get_first ( ) const
inline

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().

◆ get_first_ne() [1/2]

template<typename T >
const Node * Aleph::Slist< T >::get_first_ne ( ) const
inlinenoexcept

Return the first node without checking emptiness (const overload).

Definition at line 161 of file tpl_slist.H.

References Aleph::Slink::get_next().

◆ get_first_ne() [2/2]

template<typename T >
Node * Aleph::Slist< T >::get_first_ne ( )
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_first()

template<typename T >
void Aleph::Slist< T >::insert_first ( Node node)
inline

Insert node right after this sentinel (at the beginning).

Parameters
[in]nodepointer 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().

Referenced by TEST(), TEST(), TEST(), and TEST().

◆ remove_first()

template<typename T >
Node * Aleph::Slist< T >::remove_first ( )
inline

Remove the first node of the list.

Exceptions
underflow_errorif the list is empty
Returns
pointer to the removed node

Definition at line 134 of file tpl_slist.H.

References ah_underflow_error_if, Aleph::Slink::is_empty(), and Aleph::Snode< T >::remove_next().

Referenced by TEST(), TEST(), and TEST().

◆ remove_first_ne()

template<typename T >
Node * Aleph::Slist< T >::remove_first_ne ( )
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().


The documentation for this class was generated from the following file: