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

#include <bidilist.hpp>

Inheritance diagram for BidiList< TElement >:
[legend]
Collaboration diagram for BidiList< TElement >:
[legend]

Class Description

template<typename TElement>
struct aworx::lib::BidiList< TElement >


Implements a doubly linked list of TElement instances. This class inherits BidiNode<TElement>, like TElement does (by contract). This way methods that return a pointer to BidiNode<TElement> may return either this object itself (the "start hook" of the list) or a pointer to an element instance.

Other methods (the larger part) accept or return object(s) of type TElement. It has to be taken care that the result of methods that return type BidiNode are not casted to pointers of TElement by the calling code (which is statically possible!). Only if a method returns TElement, it is assured that a custom element type is returned.

Template Parameters
TElementThe "final" custom type that (by contract) is derived from BidiNode the same type as this struct is.

Definition at line 24 of file bidilist.hpp.

Public Types

using ConstIterator = BidiListIterator< const TElement >
 
using ConstReverseIterator = std::reverse_iterator< ConstIterator >
 
using Iterator = BidiListIterator< TElement >
 
using ReverseIterator = std::reverse_iterator< Iterator >
 
using TFNode = ForwardNode< TElement >
 
using TNode = BidiNode< TElement >
 

Public Methods

 BidiList () noexcept
 
 BidiList (BidiList &&move) noexcept
 
 BidiList (const BidiList &)=delete
 
 BidiList (TElement *first)
 
 BidiList (TElement *first, TElement *last)
 
Iterator begin ()
 
ConstIterator begin () const
 
TNodecastToNode ()
 
ConstIterator cbegin () const
 
ConstIterator cend () const
 
integer count (TElement *end=nullptr) const
 
ConstReverseIterator crbegin () const
 
ConstReverseIterator crend () const
 
Iterator end ()
 
ConstIterator end () const
 
TElement * first () const
 
bool isEmpty () const
 
bool isFirst (TElement *elem) const
 
bool isLast (TElement *elem) const
 
bool isNotEmpty () const
 
TElement * last () const
 
BidiListoperator= (BidiList &&) noexcept=default
 
BidiListoperator= (const BidiList &)=delete
 
TElement * popEnd ()
 
TElement * popFront ()
 
void pushEnd (TElement *elem)
 
void pushEnd (TElement *first, TElement *last)
 
void pushFront (TElement *elem)
 
void pushFront (TElement *first, TElement *last)
 
ReverseIterator rbegin ()
 
ConstReverseIterator rbegin () const
 
ReverseIterator rend ()
 
ConstReverseIterator rend () const
 
void reset ()
 
TElement * stopper () const
 

Additional Inherited Members

- Private Static Methods inherited from ForwardNode< TElement >
static integer count (TElement *start, TElement *end=nullptr)
 
static void moveForward (TElement *&pointer)
 
static TElement * moveForward (TNode *&pointer)
 
- Private Methods inherited from BidiNode< TElement >
 BidiNode () noexcept=default
 
 BidiNode (const TNode &)=delete
 
 BidiNode (TElement *next, TElement *previous) noexcept
 
 BidiNode (TNode &&) noexcept=default
 
void addBefore (TElement *elem)
 
void addBefore (TElement *first, TElement *last)
 
void addBehind (TElement *elem)
 
void addBehind (TElement *first, TElement *last)
 
TElement * next () const
 
BidiNodeoperator= (const TNode &)=delete
 
BidiNodeoperator= (TNode &&) noexcept=default
 
TElement * prev () const
 
void remove ()
 
void remove (TElement *last)
 
TElement * self ()
 
- Private Methods inherited from ForwardNode< TElement >
 ForwardNode () noexcept=default
 
 ForwardNode (const TNode &)=delete
 
 ForwardNode (TElement *next) noexcept
 
 ForwardNode (TNode &&) noexcept=default
 
TElement * addBehind (TElement *elem)
 
TElement * addBehind (TElement *first, TElement *last)
 
Iterator begin ()
 
ConstIterator begin () const
 
ConstIterator cbegin () const
 
ConstIterator cend () const
 
Iterator end ()
 
ConstIterator end () const
 
bool hasNext () const
 
bool isLast () const
 
TElement * makeLast ()
 
TElement * makePointTo (TElement *elem)
 
TElement * next () const
 
ForwardNodeoperator= (const TNode &)=delete
 
ForwardNodeoperator= (TNode &&) noexcept=default
 
bool pointsTo (TElement *elem) const
 
TElement * removeNext ()
 
TElement * removeRangeBehind (TElement *last)
 
- Private Types inherited from BidiNode< TElement >
using TFNode = ForwardNode< TElement >
 
using TNode = BidiNode< TElement >
 
- Private Types inherited from ForwardNode< TElement >
using ConstIterator = ForwardListIterator< const TElement >
 
using Iterator = ForwardListIterator< TElement >
 
using TNode = ForwardNode< TElement >
 

Member Typedef Documentation

◆ ConstIterator

using ConstIterator = BidiListIterator<const TElement>

The constant iterator type.

Definition at line 561 of file bidilist.hpp.

◆ ConstReverseIterator

using ConstReverseIterator = std::reverse_iterator<ConstIterator>

The constant reverse iterator type.

Definition at line 567 of file bidilist.hpp.

◆ Iterator

using Iterator = BidiListIterator< TElement>

The mutable iterator type.

Definition at line 558 of file bidilist.hpp.

◆ ReverseIterator

using ReverseIterator = std::reverse_iterator< Iterator>

The mutable reverse iterator type.

Definition at line 564 of file bidilist.hpp.

◆ TFNode

using TFNode = ForwardNode<TElement>

An alias for the base type of the node type of this list.

Definition at line 343 of file bidilist.hpp.

◆ TNode

using TNode = BidiNode<TElement>

An alias for the node type of this list, which is also the type this struct is derived from.

Definition at line 347 of file bidilist.hpp.

Constructor & Destructor Documentation

◆ BidiList() [1/5]

BidiList ( )
inlinenoexcept

Default constructor. Initializes this list to be empty.

Definition at line 350 of file bidilist.hpp.

◆ BidiList() [2/5]

BidiList ( const BidiList< TElement > &  )
delete

Deleted copy constructor.

◆ BidiList() [3/5]

BidiList ( BidiList< TElement > &&  move)
inlinenoexcept

Defaulted move constructor.

Parameters
moveThe list to move.

Definition at line 362 of file bidilist.hpp.

◆ BidiList() [4/5]

BidiList ( TElement *  first)
inline

Constructor accepting a pointer to the first element.

Parameters
firstThe element to use as the first element of this list.

Definition at line 388 of file bidilist.hpp.

◆ BidiList() [5/5]

BidiList ( TElement *  first,
TElement *  last 
)
inline

Constructor accepting a pointer to the first and last element.

Parameters
firstThe element to use as the first element of this list.
lastThe element to use as the last element of this list.

Definition at line 399 of file bidilist.hpp.

Member Function Documentation

◆ begin() [1/2]

Iterator begin ( )
inline

Returns an iterator referring to a mutable element at the start of this list.

Returns
An iterator to the first element in the list.

Definition at line 573 of file bidilist.hpp.

◆ begin() [2/2]

ConstIterator begin ( ) const
inline

Returns an iterator referring to a constant element at the start of this list.

Returns
An iterator to the first element in the list, limited to constant element access.

Definition at line 581 of file bidilist.hpp.

◆ castToNode()

TNode* castToNode ( )
inline

Casts this list to the node type. This method is needed because this list type inherits the node type privately.

Note
This method simply returns this, which performs the static cast. If this type inherited BidiNode publically, a simple ampersand operator (&) could be used on a value of this type instead of invoking this method.
Returns
Returns this list as a pointer to base type BidiNode.

Definition at line 417 of file bidilist.hpp.

◆ cbegin()

ConstIterator cbegin ( ) const
inline

Returns an iterator referring to a constant element at the start of this list.

Returns
An iterator to the first element in the list, limited to constant element access.

Definition at line 589 of file bidilist.hpp.

◆ cend()

ConstIterator cend ( ) const
inline

Returns an iterator referring to a constant, non-existing element.

Returns
The end of the list.

Definition at line 593 of file bidilist.hpp.

◆ 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 541 of file bidilist.hpp.

Here is the caller graph for this function:

◆ crbegin()

ConstReverseIterator crbegin ( ) const
inline

Returns an iterator referring to a constant element at the start of this list.

Returns
An iterator to the first element in the list, limited to constant element access.

Definition at line 613 of file bidilist.hpp.

◆ crend()

ConstReverseIterator crend ( ) const
inline

Returns an iterator referring to a constant, non-existing element.

Returns
The end of the list.

Definition at line 617 of file bidilist.hpp.

◆ end() [1/2]

Iterator end ( )
inline

Returns an iterator referring to a mutable, non-existing element.

Returns
The end of the list.

Definition at line 577 of file bidilist.hpp.

Here is the caller graph for this function:

◆ end() [2/2]

ConstIterator end ( ) const
inline

Returns an iterator referring to a constant, non-existing element.

Returns
The end of the list.

Definition at line 585 of file bidilist.hpp.

◆ first()

TElement* first ( ) const
inline

Returns the first element of this list.

Returns
The first element of this list.

Definition at line 445 of file bidilist.hpp.

Here is the caller graph for this function:

◆ isEmpty()

bool isEmpty ( ) const
inline

Tests if this list is empty.

Returns
false if the list is empty, true otherwise.

Definition at line 424 of file bidilist.hpp.

Here is the caller graph for this function:

◆ isFirst()

bool isFirst ( TElement *  elem) const
inline

Tests if given elem is the first element of this list.

Parameters
elemThe element to test for being the first.
Returns
true if elem is the first element of this list, false otherwise.

Definition at line 460 of file bidilist.hpp.

◆ isLast()

bool isLast ( TElement *  elem) const
inline

Tests if given elem is the last element of this list.

Parameters
elemThe element to test for being the last.
Returns
true if elem is the last element of this list, false otherwise.

Definition at line 468 of file bidilist.hpp.

◆ isNotEmpty()

bool isNotEmpty ( ) const
inline

Tests if this list is not empty.

Returns
true if the list is empty, false otherwise.

Definition at line 431 of file bidilist.hpp.

◆ last()

TElement* last ( ) const
inline

Returns the last element of this list.

Returns
The last element of this list.

Definition at line 452 of file bidilist.hpp.

Here is the caller graph for this function:

◆ operator=() [1/2]

BidiList& operator= ( BidiList< TElement > &&  )
defaultnoexcept

Defaulted move assignment operator.

Returns
A reference to this list object.

◆ operator=() [2/2]

BidiList& operator= ( const BidiList< TElement > &  )
delete

Deleted copy assignment operator.

Returns
A reference to this list object.

◆ popEnd()

TElement* popEnd ( )
inline

Removes and returns the last element from this list. Must not be invoked on empty lists.

Returns
A pointer to the last element (which was removed).

Definition at line 528 of file bidilist.hpp.

◆ popFront()

TElement* popFront ( )
inline

Removes and returns the first element from this list. Must not be invoked on empty lists.

Returns
A pointer to the first element (which was removed).

Definition at line 518 of file bidilist.hpp.

◆ pushEnd() [1/2]

void pushEnd ( 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 501 of file bidilist.hpp.

Here is the caller graph for this function:

◆ pushEnd() [2/2]

void pushEnd ( 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 509 of file bidilist.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 485 of file bidilist.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 494 of file bidilist.hpp.

◆ rbegin() [1/2]

ReverseIterator rbegin ( )
inline

Returns an iterator referring to a mutable element at the start of this list.

Returns
An iterator to the first element in the list.

Definition at line 597 of file bidilist.hpp.

◆ rbegin() [2/2]

ConstReverseIterator rbegin ( ) const
inline

Returns an iterator referring to a constant element at the start of this list.

Returns
An iterator to the first element in the list, limited to constant element access.

Definition at line 605 of file bidilist.hpp.

◆ rend() [1/2]

ReverseIterator rend ( )
inline

Returns an iterator referring to a mutable, non-existing element.

Returns
The end of the list.

Definition at line 601 of file bidilist.hpp.

◆ rend() [2/2]

ConstReverseIterator rend ( ) const
inline

Returns an iterator referring to a constant, non-existing element.

Returns
The end of the list.

Definition at line 609 of file bidilist.hpp.

◆ reset()

void reset ( )
inline

Resets this list to zero elements.

Definition at line 437 of file bidilist.hpp.

Here is the caller graph for this function:

◆ stopper()

TElement* stopper ( ) const
inline

Returns an "illegal" stopper element. This is illegal in respect to that it must not be dereferenced, as in fact the returned object is a node, but not an element including the custom value.

Returns
A "stopper" element to determine the end of the list.

Definition at line 477 of file bidilist.hpp.

Here is the caller graph for this function:

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