|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Dynamic list of elements of type T implemented with a singly linked list of nodes.
More...
#include <tpl_dynSlist.H>
Classes | |
| class | Iterator |
Iterator specialized for DynSlist returning payload references. More... | |
Public Member Functions | |
| DynSlist () | |
| Constructor. | |
| DynSlist (const DynSlist &other) | |
| DynSlist & | operator= (const DynSlist &other) |
| DynSlist (DynSlist &&other) noexcept | |
| DynSlist & | operator= (DynSlist &&other) noexcept |
| T & | operator[] (const size_t i) |
Access the element at position i. | |
| const T & | operator[] (const size_t i) const |
Const overload of operator[]. | |
| size_t | size () const noexcept |
| Return the number of stored elements. | |
| void | insert (const int pos, const T &data) |
Insert an element at position pos. | |
| void | insert (const int pos, T &&data) |
| Insert an element by moving the provided value. | |
| void | remove (const int pos) |
Remove the node at position pos. | |
| virtual | ~DynSlist () |
Public Member Functions inherited from Aleph::Slist< T > | |
| 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. | |
Private Member Functions | |
| void | clear () noexcept |
| Slist< T >::Node * | get_previous_to_pos (const size_t pos, const bool allow_equal) |
Private Attributes | |
| size_t | num_items |
| size_t | current_pos |
| Snode< T > * | current_node |
Additional Inherited Members | |
Public Types inherited from Aleph::Slist< T > | |
| typedef Snode< T > | Node |
Protected Attributes inherited from Aleph::Slink | |
| Slink * | next |
Dynamic list of elements of type T implemented with a singly linked list of nodes.
| T | data type stored in each node |
Definition at line 61 of file tpl_dynSlist.H.
|
inline |
Constructor.
Definition at line 97 of file tpl_dynSlist.H.
|
inline |
Definition at line 102 of file tpl_dynSlist.H.
References Aleph::DynSlist< T >::current_node, Aleph::DynSlist< T >::current_pos, Aleph::DynList< T >::get_first_ne(), Aleph::Snode< T >::get_next(), Aleph::maps(), Aleph::next(), and Aleph::DynSlist< T >::num_items.
|
inlinenoexcept |
Definition at line 206 of file tpl_dynSlist.H.
References Aleph::DynSlist< T >::current_node, Aleph::DynSlist< T >::current_pos, Aleph::Snode< T >::get_next(), Aleph::HTList::is_empty(), Aleph::maps(), Aleph::DynSlist< T >::num_items, and Aleph::HTList::reset().
Definition at line 340 of file tpl_dynSlist.H.
References Aleph::DynSlist< T >::clear().
|
inlineprivatenoexcept |
Definition at line 67 of file tpl_dynSlist.H.
References Aleph::DynSlist< T >::current_node, Aleph::DynSlist< T >::current_pos, Aleph::Slink::is_empty(), Aleph::maps(), and Aleph::Slist< T >::remove_first_ne().
Referenced by Aleph::DynSlist< T >::~DynSlist(), Aleph::DynSlist< T >::operator=(), and Aleph::DynSlist< T >::operator=().
|
inlineprivate |
Definition at line 76 of file tpl_dynSlist.H.
References ah_out_of_range_error_if, Aleph::DynSlist< T >::current_node, Aleph::DynSlist< T >::current_pos, Aleph::Snode< T >::get_next(), Aleph::maps(), and Aleph::DynSlist< T >::num_items.
Referenced by Aleph::DynSlist< T >::insert(), Aleph::DynSlist< T >::insert(), Aleph::DynSlist< T >::operator[](), and Aleph::DynSlist< T >::remove().
Insert an element at position pos.
| [in] | pos | insertion position in [0, size()] |
| [in] | data | value to store |
| std::out_of_range | if pos is invalid |
| std::bad_alloc | on memory exhaustion |
Definition at line 304 of file tpl_dynSlist.H.
References Aleph::DynSlist< T >::current_node, Aleph::DynSlist< T >::current_pos, Aleph::Snode< T >::data, Aleph::DynSlist< T >::get_previous_to_pos(), and Aleph::DynSlist< T >::num_items.
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
Insert an element by moving the provided value.
Definition at line 315 of file tpl_dynSlist.H.
References Aleph::DynSlist< T >::current_node, Aleph::DynSlist< T >::current_pos, Aleph::Snode< T >::data, Aleph::DynSlist< T >::get_previous_to_pos(), and Aleph::DynSlist< T >::num_items.
|
inline |
Definition at line 151 of file tpl_dynSlist.H.
References Aleph::DynSlist< T >::clear(), Aleph::DynSlist< T >::current_node, Aleph::DynSlist< T >::current_pos, Aleph::DynList< T >::get_first_ne(), Aleph::Snode< T >::get_next(), Aleph::maps(), Aleph::next(), and Aleph::DynSlist< T >::num_items.
|
inlinenoexcept |
Definition at line 233 of file tpl_dynSlist.H.
References Aleph::DynSlist< T >::clear(), Aleph::DynSlist< T >::current_node, Aleph::DynSlist< T >::current_pos, Aleph::Snode< T >::get_next(), Aleph::HTList::is_empty(), Aleph::maps(), Aleph::DynSlist< T >::num_items, and Aleph::HTList::reset().
|
inline |
Access the element at position i.
Access is O(i) because it requires traversing i nodes.
| [in] | i | zero-based index to access |
| std::out_of_range | if i is outside [0, size()] |
i Definition at line 275 of file tpl_dynSlist.H.
References Aleph::Snode< T >::get_data(), Aleph::Snode< T >::get_next(), and Aleph::DynSlist< T >::get_previous_to_pos().
|
inline |
Const overload of operator[].
Definition at line 281 of file tpl_dynSlist.H.
References ah_out_of_range_error_if, Aleph::Slist< T >::get_first_ne(), Aleph::maps(), and Aleph::DynSlist< T >::num_items.
Remove the node at position pos.
| [in] | pos | zero-based position to erase |
| std::out_of_range | if pos is invalid |
Definition at line 330 of file tpl_dynSlist.H.
References Aleph::DynSlist< T >::current_node, Aleph::DynSlist< T >::current_pos, Aleph::DynSlist< T >::get_previous_to_pos(), Aleph::maps(), and Aleph::DynSlist< T >::num_items.
|
inlinenoexcept |
Return the number of stored elements.
Definition at line 295 of file tpl_dynSlist.H.
References Aleph::DynSlist< T >::num_items.
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
Definition at line 65 of file tpl_dynSlist.H.
Referenced by Aleph::DynSlist< T >::DynSlist(), Aleph::DynSlist< T >::DynSlist(), Aleph::DynSlist< T >::clear(), Aleph::DynSlist< T >::get_previous_to_pos(), Aleph::DynSlist< T >::insert(), Aleph::DynSlist< T >::insert(), Aleph::DynSlist< T >::operator=(), Aleph::DynSlist< T >::operator=(), and Aleph::DynSlist< T >::remove().
|
private |
Definition at line 64 of file tpl_dynSlist.H.
Referenced by Aleph::DynSlist< T >::DynSlist(), Aleph::DynSlist< T >::DynSlist(), Aleph::DynSlist< T >::clear(), Aleph::DynSlist< T >::get_previous_to_pos(), Aleph::DynSlist< T >::insert(), Aleph::DynSlist< T >::insert(), Aleph::DynSlist< T >::operator=(), Aleph::DynSlist< T >::operator=(), and Aleph::DynSlist< T >::remove().
|
private |
Definition at line 63 of file tpl_dynSlist.H.
Referenced by Aleph::DynSlist< T >::DynSlist(), Aleph::DynSlist< T >::DynSlist(), Aleph::DynSlist< T >::get_previous_to_pos(), Aleph::DynSlist< T >::insert(), Aleph::DynSlist< T >::insert(), Aleph::DynSlist< T >::operator=(), Aleph::DynSlist< T >::operator=(), Aleph::DynSlist< T >::operator[](), Aleph::DynSlist< T >::remove(), and Aleph::DynSlist< T >::size().