ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::lang::SidiListHook< TElement > Struct Template Reference

Description:

template<typename TElement>
struct alib::lang::SidiListHook< TElement >

This class, together with sibling class lang::SidiNodeBase provide the tools to implement a single linked list of TElement instances.

See also
Types lang::SidiNodeBase,
lang::BidiNodeBase, and
lang::BidiListHook.
Template Parameters
TElementThe "final" custom type that (by contract) is derived from lang::SidiNodeBase.

Definition at line 185 of file sidilist.inl.

Inheritance diagram for alib::lang::SidiListHook< TElement >:
[legend]
Collaboration diagram for alib::lang::SidiListHook< TElement >:
[legend]

Public Type Index:

using TNode = SidiNodeBase<TElement>
 An alias for the node type.
 

Public Method Index:

 SidiListHook () noexcept
 Default constructor. Initializes this list to be empty.
 
 SidiListHook (const SidiListHook &copy)=delete
 
 SidiListHook (SidiListHook &&) noexcept=default
 
integer count (TElement *end=nullptr) const noexcept
 
TNodefindAndRemove (TElement *elem) noexcept
 
TElement * findLast () const noexcept
 
TElement * findLast (TElement *hint) const noexcept
 
TElement * findLastBefore (TElement *elem) noexcept
 
TElement * first () const noexcept
 
bool isEmpty () const noexcept
 
SidiListHookoperator= (const SidiListHook &) noexcept=delete
 
SidiListHookoperator= (SidiListHook &&) noexcept=default
 
TElement * popFront () noexcept
 
void pushFront (TElement *elem) noexcept
 
void pushFront (TElement *first, TElement *last)
 
void reset () noexcept
 Resets this list to zero elements.
 
- Public Method Index: inherited from alib::lang::SidiNodeBase< TElement >
 SidiNodeBase () noexcept=default
 Default constructor. (Does not initialize the pointer.)
 
 SidiNodeBase (const SidiNodeBase &)=delete
 
 SidiNodeBase (SidiNodeBase &&) noexcept=default
 Defaulted move constructor.
 
 SidiNodeBase (TElement *next) noexcept
 
TElement * addBehind (TElement *elem) noexcept
 
integer count (SidiNodeBase *end=nullptr) const noexcept
 
bool hasNext () const
 
TElement * next () const
 
void next (SidiNodeBase *p)
 
SidiNodeBaseoperator= (const SidiNodeBase &)=delete
 
SidiNodeBaseoperator= (SidiNodeBase &&) noexcept=default
 
bool pointsTo (const SidiNodeBase *elem) const
 
TElement * removeNext () noexcept
 
TElement * removeRangeBehind (TElement *last) noexcept
 

Additional Inherited Members

- Public Field Index: inherited from alib::lang::SidiNodeBase< TElement >
TElement * n
 

Type Definition Details:

◆ TNode

template<typename TElement>
using alib::lang::SidiListHook< TElement >::TNode = SidiNodeBase<TElement>

An alias for the node type.

Definition at line 188 of file sidilist.inl.

Constructor(s) / Destructor Details:

◆ SidiListHook() [1/3]

template<typename TElement>
alib::lang::SidiListHook< TElement >::SidiListHook ( )
inlinenoexcept

Default constructor. Initializes this list to be empty.

Definition at line 191 of file sidilist.inl.

◆ SidiListHook() [2/3]

template<typename TElement>
alib::lang::SidiListHook< TElement >::SidiListHook ( const SidiListHook< TElement > & copy)
delete

Deleted copy constructor.

Note
Copy construction is a duty of derived usable types.

◆ SidiListHook() [3/3]

template<typename TElement>
alib::lang::SidiListHook< TElement >::SidiListHook ( SidiListHook< TElement > && )
defaultnoexcept

Move constructor. Copies the link from move and sets the link of move to nullptr.

Method Details:

◆ count()

template<typename TElement>
integer alib::lang::SidiListHook< TElement >::count ( TElement * end = nullptr) const
inlinenodiscardnoexcept

Counts the number of elements found in the range starting with this list's first element and ending with the element before end.

Parameters
endThe element after the last one to count. Defaults to a nullptr marking the end of the list.
Returns
The number of elements in the range.

Definition at line 316 of file sidilist.inl.

◆ findAndRemove()

template<typename TElement>
TNode * alib::lang::SidiListHook< TElement >::findAndRemove ( TElement * elem)
inlinenoexcept

Searches the predecessor of the given element using findLastBefore and unhooks the element from the list.

Attention
It is not checked whether a predecessor was found, aka whether elem is an element of this list. If not, the behavior is undefined (nullptr access).
Furthermore, the successor of given elem is not changed, although it is removed from the list.
Parameters
elemThe element to remove.
Returns
The node (this object) or element that pointed to given elem before the invocation and now points to the successor of elem.

Definition at line 303 of file sidilist.inl.

◆ findLast() [1/2]

template<typename TElement>
TElement * alib::lang::SidiListHook< TElement >::findLast ( ) const
inlinenodiscardnoexcept

Searches and returns the last element.

Note
This method must only be invoked on non-empty lists (isEmpty returns false). Otherwise, this method has undefined behavior (dereference of a nullptr). To find the pointer to the last element, use findLastBefore providing nullptr.
Returns
The last element of this list.

Definition at line 259 of file sidilist.inl.

◆ findLast() [2/2]

template<typename TElement>
TElement * alib::lang::SidiListHook< TElement >::findLast ( TElement * hint) const
inlinenodiscardnoexcept

Searches and returns the last element.

Parameters
hintAn element of this list used to start the search.
Returns
The last element of this list.

Definition at line 271 of file sidilist.inl.

◆ findLastBefore()

template<typename TElement>
TElement * alib::lang::SidiListHook< TElement >::findLastBefore ( TElement * elem)
inlinenodiscardnoexcept

Searches the node or element that points to the given element.

Attention
The element has to exist. Otherwise, a nullptr exception will occur!
Parameters
elemThe element to search for.
Returns
The node (this object) or element pointing to elem.

Definition at line 284 of file sidilist.inl.

◆ first()

template<typename TElement>
TElement * alib::lang::SidiListHook< TElement >::first ( ) const
inlinenodiscardnoexcept

Returns the start element of this list.

Returns
The first element of this list, respectively nullptr if this list is empty.

Definition at line 223 of file sidilist.inl.

◆ isEmpty()

template<typename TElement>
bool alib::lang::SidiListHook< TElement >::isEmpty ( ) const
inlinenodiscardnoexcept

Tests if this list is empty.

Returns
false if the list is empty, true otherwise.

Definition at line 215 of file sidilist.inl.

◆ operator=() [1/2]

template<typename TElement>
SidiListHook & alib::lang::SidiListHook< TElement >::operator= ( const SidiListHook< TElement > & )
deletenoexcept

Deleted copy assignment operator.

Returns
Not applicable

◆ operator=() [2/2]

template<typename TElement>
SidiListHook & alib::lang::SidiListHook< TElement >::operator= ( SidiListHook< TElement > && )
defaultnoexcept

Move assignment operator. Copies the link to the first element from move and sets the link in move to nullptr.

Returns
A reference to this list object.

◆ popFront()

template<typename TElement>
TElement * alib::lang::SidiListHook< TElement >::popFront ( )
inlinenoexcept

Removes and returns the first element from this list.

Returns
A pointer to the element, respectively nullptr if the list was empty.

Definition at line 244 of file sidilist.inl.

◆ pushFront() [1/2]

template<typename TElement>
void alib::lang::SidiListHook< TElement >::pushFront ( TElement * elem)
inlinenoexcept

Hooks the given element to the beginning of this list.

Parameters
elemThe element to insert to at the start.

Definition at line 227 of file sidilist.inl.

◆ pushFront() [2/2]

template<typename TElement>
void alib::lang::SidiListHook< TElement >::pushFront ( TElement * first,
TElement * last )
inline

Hooks the given range of elements to the front of this list.

Parameters
firstThe first element of the range to insert.
lastThe last element of the range to insert.

Definition at line 236 of file sidilist.inl.

◆ reset()

template<typename TElement>
void alib::lang::SidiListHook< TElement >::reset ( )
inlinenoexcept

Resets this list to zero elements.

Definition at line 218 of file sidilist.inl.


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