#include <forwardlist.hpp>
Implements a single linked list of TElement instances. This class inherits ForwardNode<TElement>, like TElement does (by contract). This way methods that return a pointer to ForwardNode<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) return an object of TElement. It has to be taken care that the result of methods that return type ForwardNode 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.
| TElement | The "final" custom type that (by contract) is derived from ForwardNode the same type as this struct is. |
Definition at line 22 of file forwardlist.hpp.
Public Types | |
| using | ConstIterator = ForwardListIterator< const TElement > |
| using | Iterator = ForwardListIterator< TElement > |
| using | TNode = ForwardNode< TElement > |
Public Methods | |
| ForwardList () noexcept | |
| ForwardList (const ForwardList ©) noexcept | |
| ForwardList (ForwardList &&move) noexcept | |
| ForwardList (TElement *first) noexcept | |
| Iterator | begin () |
| ConstIterator | begin () const |
| TNode * | castToNode () |
| ConstIterator | cbegin () const |
| ConstIterator | cend () const |
| integer | count (TElement *end=nullptr) const |
| Iterator | end () |
| ConstIterator | end () const |
| TNode * | findAndRemove (TElement *elem) |
| TElement * | findLast () const |
| TElement * | findLast (TElement *hint) const |
| TNode * | findLastBefore (TElement *elem) |
| bool | isEmpty () const |
| bool | isNotEmpty () const |
| ForwardList & | operator= (const ForwardList ©) noexcept |
| ForwardList & | operator= (ForwardList &&move) noexcept |
| TElement * | popFront () |
| void | pushFront (TElement *elem) |
| void | pushFront (TElement *first, TElement *last) |
| void | reset () |
| void | setStart (TElement *elem) |
| TElement * | start () 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 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 |
| ForwardNode & | operator= (const TNode &)=delete |
| ForwardNode & | operator= (TNode &&) noexcept=default |
| bool | pointsTo (TElement *elem) const |
| TElement * | removeNext () |
| TElement * | removeRangeBehind (TElement *last) |
Private Types inherited from ForwardNode< TElement > | |
| using | ConstIterator = ForwardListIterator< const TElement > |
| using | Iterator = ForwardListIterator< TElement > |
| using | TNode = ForwardNode< TElement > |
| using ConstIterator = ForwardListIterator<const TElement> |
The constant iterator type.
Definition at line 625 of file forwardlist.hpp.
| using Iterator = ForwardListIterator< TElement> |
The mutable iterator type.
Definition at line 622 of file forwardlist.hpp.
| using TNode = ForwardNode<TElement> |
An alias for the node type of this list, which is also the type this struct is derived from.
Definition at line 422 of file forwardlist.hpp.
|
inlinenoexcept |
Default constructor. Initializes this list to be empty.
Definition at line 427 of file forwardlist.hpp.
|
inlinenoexcept |
Copy constructor. After construction, this instance points to the first start object as copy does.
| copy | The list to copy the link from. |
Definition at line 435 of file forwardlist.hpp.
|
inlinenoexcept |
Move constructor. Copies the link from move and sets the link of move to nullptr.
| move | The list to move. |
Definition at line 444 of file forwardlist.hpp.
|
inlinenoexcept |
Constructor accepting a pointer to the first element.
| first | The element to use as the first element of this list. |
Definition at line 473 of file forwardlist.hpp.
|
inline |
Returns an iterator referring to a mutable element at the start of this list.
Definition at line 629 of file forwardlist.hpp.
|
inline |
Returns an iterator referring to a constant element at the start of this list.
Definition at line 637 of file forwardlist.hpp.
|
inline |
Casts this list to the node type. This method is needed because this list type inherits the node type privately.
this, which performs the static cast. If this type inherited ForwardNode publically, a simple ampersand operator (&) could be used on a value of this type instead of invoking this method.Definition at line 487 of file forwardlist.hpp.
|
inline |
Returns an iterator referring to a constant element at the start of this list.
Definition at line 645 of file forwardlist.hpp.
|
inline |
Returns an iterator referring to a constant, non-existing element.
Definition at line 649 of file forwardlist.hpp.
|
inline |
Counts the number of elements found in the range starting with this list's first element and ending with the element before end.
| end | The element after the last one to count. Defaults to a nullptr marking the end of the list. |
Definition at line 615 of file forwardlist.hpp.
|
inline |
Returns an iterator referring to a mutable, non-existing element.
Definition at line 633 of file forwardlist.hpp.
|
inline |
Returns an iterator referring to a constant, non-existing element.
Definition at line 641 of file forwardlist.hpp.
|
inline |
Searches the predecessor of the given element using findLastBefore and unhooks the element from the list.
nullptr access).| elem | The element to remove. |
Definition at line 603 of file forwardlist.hpp.
|
inline |
Searches and returns the last element.
true). Otherwise this method has undefined behavior (dereference of a nullptr). To find the pointer to the last element use findLastBefore providing nullptr. Definition at line 562 of file forwardlist.hpp.
|
inline |
Searches and returns the last element.
| hint | An element of this list used to start the search. |
Definition at line 573 of file forwardlist.hpp.
|
inline |
Searches the node or element that points to the given element.
| elem | The element to search for. |
Definition at line 584 of file forwardlist.hpp.
|
inline |
Tests if this list is empty.
false if the list is empty, true otherwise. Definition at line 494 of file forwardlist.hpp.
|
inline |
Tests if this list is not empty.
true if the list is empty, false otherwise. Definition at line 501 of file forwardlist.hpp.
|
inlinenoexcept |
Copy assignment operator. Copies the link to the first element from copy.
| copy | The list to copy the link from. |
Definition at line 454 of file forwardlist.hpp.
|
inlinenoexcept |
Move assignment operator. Copies the link to the first element from move and sets the link in move to nullptr.
| move | The list to move the link from. |
Definition at line 464 of file forwardlist.hpp.
|
inline |
Removes and returns the first element from this list.
nullptr if the list was empty. Definition at line 546 of file forwardlist.hpp.
|
inline |
Hooks the given element to the beginning of this list.
| elem | The element to insert to at the start. |
Definition at line 529 of file forwardlist.hpp.
|
inline |
Hooks the given range of elements to the front of this list.
| first | The first element of the range to insert. |
| last | The last element of the range to insert. |
Definition at line 538 of file forwardlist.hpp.
|
inline |
Resets this list to zero elements.
Definition at line 507 of file forwardlist.hpp.
|
inline |
Sets given element elem as the start of this list.
| elem | The element to set as the new start of this list. |
Definition at line 522 of file forwardlist.hpp.
|
inline |
Returns the start element of this list.
nullptr if this list is empty. Definition at line 514 of file forwardlist.hpp.