Yggdrasill
0.2
|
An intrusive doubly-linked list class. More...
#include <list.hpp>
Classes | |
class | const_iterator |
Const iterator over all elements in the list. More... | |
class | iterator |
Iterator over all elements in the list. More... | |
Public Types | |
using | NB = ListNodeBase< Node, Tag > |
Public Member Functions | |
List () | |
void | insert (Node *next, Node *n) |
Insert a node into the list. More... | |
void | remove (Node *n) |
Remove a node from the list. More... | |
iterator | begin () |
const_iterator | begin () const |
iterator | end () |
const_iterator | end () const |
iterator | back () |
const_iterator | back () const |
const_iterator | iterator_to (const Node &n) const |
iterator | iterator_to (const Node &n) |
size_t | size () const |
Returns the number of elements in the list. More... | |
bool | empty () const |
Returns whether the list is empty. More... | |
void | clear () |
Removes all elements from this list. More... | |
An intrusive doubly-linked list class.
This class serves as an intrusive doubly-linked list on the nodes.
Node | The class of the nodes is this list. Must be derived from ListNodeBase. |
Tag | An class tag that identifies this list. Can be used to insert the same nodes into multiple lists. See DOCTODO for details. Can be any class, the class can be empty. Must be the same tag as specified for the nodes. |
ygg::List< Node, Options, Tag >::List | ( | ) |
Constructs an empty list.
iterator ygg::List< Node, Options, Tag >::back | ( | ) |
Returns an iterator pointing to the last element in the list.
iterator ygg::List< Node, Options, Tag >::begin | ( | ) |
Returns an iterator pointing to the first element in the list.
void ygg::List< Node, Options, Tag >::clear | ( | ) |
Removes all elements from this list.
This method runs in O(1).
bool ygg::List< Node, Options, Tag >::empty | ( | ) | const |
Returns whether the list is empty.
This method runs in O(1).
iterator ygg::List< Node, Options, Tag >::end | ( | ) |
Returns an iterator pointing after the last element in the list.
void ygg::List< Node, Options, Tag >::insert | ( | Node * | next, |
Node * | n | ||
) |
Insert a node into the list.
This inserts Node n into the list, right before next. To insert a node at the end of the list, set next to nullptr.
next | The node that n should be inserted before. Set to nullptr to insert n at the end of the list. |
n | The node to be inserted into the list. |
const_iterator ygg::List< Node, Options, Tag >::iterator_to | ( | const Node & | n | ) | const |
Returns an iterator pointing to n in the list
n | The node to which a pointer should be returned. |
void ygg::List< Node, Options, Tag >::remove | ( | Node * | n | ) |
Remove a node from the list.
n | The node to be removed from the list. |
size_t ygg::List< Node, Options, Tag >::size | ( | ) | const |
Returns the number of elements in the list.
This method runs in O(1).