ALib C++ Library
Library Version: 2312 R0
Documentation generated by doxygen
Public Types | Public Fields | Public Methods | List of all members
SidiListHelper< TElement > Struct Template Reference

#include <sidilist.hpp>

Class Description

template<typename TElement>
struct aworx::lib::detail::SidiListHelper< TElement >


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

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

Definition at line 198 of file sidilist.hpp.

Public Types

using TNode = SidiNodeBase< TElement >
 

Public Fields

TNode hook
 

Public Methods

 SidiListHelper () noexcept
 
 SidiListHelper (const SidiListHelper &copy)=delete
 
 SidiListHelper (SidiListHelper &&) noexcept=default
 
integer count (TElement *end=nullptr) const
 
TNodefindAndRemove (TElement *elem)
 
TElement * findLast () const
 
TElement * findLast (TElement *hint) const
 
TElement * findLastBefore (TElement *elem)
 
TElement * first () const
 
bool isEmpty () const
 
SidiListHelperoperator= (const SidiListHelper &) noexcept=delete
 
SidiListHelperoperator= (SidiListHelper &&) noexcept=default
 
TElement * popFront ()
 
void pushFront (TElement *elem)
 
void pushFront (TElement *first, TElement *last)
 
void reset ()
 

Member Typedef Documentation

◆ TNode

using TNode = SidiNodeBase<TElement>

An alias for the node type.

Definition at line 201 of file sidilist.hpp.

Constructor & Destructor Documentation

◆ SidiListHelper() [1/3]

SidiListHelper ( )
inlinenoexcept

Default constructor. Initializes this list to be empty.

Definition at line 207 of file sidilist.hpp.

◆ SidiListHelper() [2/3]

SidiListHelper ( const SidiListHelper< TElement > &  copy)
delete

Deleted copy constructor.

Note
Copy construction is a duty of derived useable types.

◆ SidiListHelper() [3/3]

SidiListHelper ( SidiListHelper< TElement > &&  )
defaultnoexcept

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

Member Function Documentation

◆ count()

integer count ( TElement *  end = nullptr) const
inline

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 336 of file sidilist.hpp.

◆ findAndRemove()

TNode* findAndRemove ( TElement *  elem)
inline

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, 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 324 of file sidilist.hpp.

◆ findLast() [1/2]

TElement* findLast ( ) const
inline

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 282 of file sidilist.hpp.

◆ findLast() [2/2]

TElement* findLast ( TElement *  hint) const
inline

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 293 of file sidilist.hpp.

◆ findLastBefore()

TElement* findLastBefore ( TElement *  elem)
inline

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 305 of file sidilist.hpp.

◆ first()

TElement* first ( ) const
inline

Returns the start element of this list.

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

Definition at line 244 of file sidilist.hpp.

◆ isEmpty()

bool isEmpty ( ) const
inline

Tests if this list is empty.

Returns
false if the list is empty, true otherwise.

Definition at line 231 of file sidilist.hpp.

◆ operator=() [1/2]

SidiListHelper& operator= ( const SidiListHelper< TElement > &  )
deletenoexcept

Deleted copy assignment operator.

Returns
Not applicable

◆ operator=() [2/2]

SidiListHelper& operator= ( SidiListHelper< 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()

TElement* popFront ( )
inline

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 268 of file sidilist.hpp.

◆ pushFront() [1/2]

void pushFront ( TElement *  elem)
inline

Hooks the given element to the beginning of this list.

Parameters
elemThe element to insert to at the start.

Definition at line 251 of file sidilist.hpp.

◆ pushFront() [2/2]

void 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 260 of file sidilist.hpp.

◆ reset()

void reset ( )
inline

Resets this list to zero elements.

Definition at line 237 of file sidilist.hpp.

Member Data Documentation

◆ hook

TNode hook

Pointer to the first node.

Definition at line 204 of file sidilist.hpp.


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