|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Link of a single linked list non-circular and without header node. More...
#include <htlist.H>
Classes | |
| class | Iterator |
| Iterator on single links. More... | |
Public Member Functions | |
| virtual | ~Slinknc ()=default |
| constexpr bool | is_empty () const noexcept |
Return true if this is empty. | |
| Slinknc () noexcept | |
| Init to nullptr. | |
| Slinknc (const Slinknc &) noexcept | |
| Dummy copy constructor. | |
| void | reset () noexcept |
| Reset the link to nullptr. | |
| Slinknc & | operator= (const Slinknc &) noexcept |
| Dummy asignation; link is set to nullptr. | |
| Slinknc *& | get_next () noexcept |
| getter | |
| void | insert (Slinknc *p) noexcept |
Insert p after this | |
| Slinknc * | remove_next () noexcept |
Remove for linked list the node pointed by this | |
| template<typename T > | |
| Snodenc< T > * | to_snodenc () noexcept |
Convert this to a Snodenc<T>. | |
| template<typename T > | |
| T & | to_data () noexcept |
| template<typename T > | |
| const Snodenc< T > * | to_snodenc () const noexcept |
| template<typename T > | |
| const T & | to_data () const noexcept |
Private Attributes | |
| Slinknc * | next = nullptr |
Link of a single linked list non-circular and without header node.
This class stores next as Slinknc*. Derived classes like Snodenc<T> need to return Snodenc<T>*& from get_next(), which requires a reinterpret_cast. This violates C++ strict aliasing rules and requires the compiler flag -fno-strict-aliasing for correct behavior.
A cleaner design would use CRTP (Curiously Recurring Template Pattern):
This refactoring is left for future work to avoid breaking changes.
|
virtualdefault |
|
inlinenoexcept |
|
inlinenoexcept |
getter
Definition at line 139 of file htlist.H.
References next.
Referenced by Aleph::Snodenc< T >::get_next(), and TEST_F().
Insert p after this
insert(p) inserts the node pointed by p after this.
| [in] | p | pointer to link (or node) |
Definition at line 159 of file htlist.H.
References Aleph::maps(), and next.
Referenced by Slinknc_of_5_items::Slinknc_of_5_items(), Aleph::insert_sorted(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
|
inlinenoexcept |
Remove for linked list the node pointed by this
Definition at line 177 of file htlist.H.
References Aleph::maps(), next, and Aleph::HTList::reset().
Referenced by Aleph::Snodenc< T >::remove_next().
|
inlinenoexcept |
Reset the link to nullptr.
Definition at line 124 of file htlist.H.
References next.
Referenced by Aleph::HTList::remove().
Definition at line 450 of file htlist.H.
References Aleph::maps().
Definition at line 101 of file htlist.H.
Referenced by get_next(), Aleph::Slinknc::Iterator::init(), insert(), is_empty(), Aleph::Slinknc::Iterator::next(), Aleph::Slinknc::Iterator::next_ne(), operator=(), remove_next(), reset(), and TEST_F().