Yggdrasill  0.2
Classes | Public Types | Public Member Functions | List of all members
ygg::List< Node, Options, Tag > Class Template Reference

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...
 

Detailed Description

template<class Node, class Options = DefaultOptions, class Tag = int>
class ygg::List< Node, Options, Tag >

An intrusive doubly-linked list class.

This class serves as an intrusive doubly-linked list on the nodes.

Template Parameters
NodeThe class of the nodes is this list. Must be derived from ListNodeBase.
TagAn 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.

Constructor & Destructor Documentation

◆ List()

template<class Node, class Options = DefaultOptions, class Tag = int>
ygg::List< Node, Options, Tag >::List ( )

Constructs an empty list.

Member Function Documentation

◆ back()

template<class Node, class Options = DefaultOptions, class Tag = int>
iterator ygg::List< Node, Options, Tag >::back ( )

Returns an iterator pointing to the last element in the list.

Returns
An iterator pointing to the last element in the list.

◆ begin()

template<class Node, class Options = DefaultOptions, class Tag = int>
iterator ygg::List< Node, Options, Tag >::begin ( )

Returns an iterator pointing to the first element in the list.

Returns
An iterator pointing to the first element in the list.

◆ clear()

template<class Node, class Options = DefaultOptions, class Tag = int>
void ygg::List< Node, Options, Tag >::clear ( )

Removes all elements from this list.

This method runs in O(1).

◆ empty()

template<class Node, class Options = DefaultOptions, class Tag = int>
bool ygg::List< Node, Options, Tag >::empty ( ) const

Returns whether the list is empty.

This method runs in O(1).

Returns
true if the list is empty, false otherwise

◆ end()

template<class Node, class Options = DefaultOptions, class Tag = int>
iterator ygg::List< Node, Options, Tag >::end ( )

Returns an iterator pointing after the last element in the list.

Returns
An iterator pointing after the last element in the list.

◆ insert()

template<class Node, class Options = DefaultOptions, class Tag = int>
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.

Parameters
nextThe node that n should be inserted before. Set to nullptr to insert n at the end of the list.
nThe node to be inserted into the list.

◆ iterator_to()

template<class Node, class Options = DefaultOptions, class Tag = int>
const_iterator ygg::List< Node, Options, Tag >::iterator_to ( const Node &  n) const

Returns an iterator pointing to n in the list

Parameters
nThe node to which a pointer should be returned.
Returns
An iterator pointing to n in the list.

◆ remove()

template<class Node, class Options = DefaultOptions, class Tag = int>
void ygg::List< Node, Options, Tag >::remove ( Node *  n)

Remove a node from the list.

Parameters
nThe node to be removed from the list.

◆ size()

template<class Node, class Options = DefaultOptions, class Tag = int>
size_t ygg::List< Node, Options, Tag >::size ( ) const

Returns the number of elements in the list.

This method runs in O(1).

Warning
This method is only available if CONSTANT_TIME_SIZE is set.
Returns
The number of elements in the list

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