nCine 2022.04.r504-20bd01e
A cross-platform 2D game engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
nctl::List< T > Class Template Reference

A double linked list based on templates. More...

#include <List.h>

Public Types

using Iterator = ListIterator< T, false >
 Iterator type.
 
using ConstIterator = ListIterator< T, true >
 Constant iterator type.
 
using ReverseIterator = nctl::ReverseIterator< Iterator >
 Reverse iterator type.
 
using ConstReverseIterator = nctl::ReverseIterator< ConstIterator >
 Reverse constant iterator type.
 

Public Member Functions

 List (const List &other)
 Copy constructor.
 
 List (List &&other)
 Move constructor.
 
Listoperator= (const List &other)
 Assignment operator.
 
Listoperator= (List &&other)
 Move assignment operator.
 
void swap (List &first, List &second)
 Swaps two lists without copying their data.
 
Iterator begin ()
 Returns an iterator to the first element.
 
ReverseIterator rBegin ()
 Returns a reverse iterator to the last element.
 
Iterator end ()
 Returns an iterator to the end of the list sentinel (valid for reverse traversal too)
 
ReverseIterator rEnd ()
 Returns a reverse iterator to the end of the list sentinel.
 
ConstIterator begin () const
 Returns a constant iterator to the first element.
 
ConstReverseIterator rBegin () const
 Returns a constant reverse iterator to the last element.
 
ConstIterator end () const
 Returns a constant iterator to the end of the list sentinel (valid reverse traversal too)
 
ConstReverseIterator rEnd () const
 Returns a constant reverse iterator to the end of the list sentinel.
 
ConstIterator cBegin () const
 Returns a constant iterator to the first element.
 
ConstReverseIterator crBegin () const
 Returns a constant reverse iterator to the last element.
 
ConstIterator cEnd () const
 Returns a constant iterator to the end of the list sentinel (valid reverse traversal too)
 
ConstReverseIterator crEnd () const
 Returns a constant reverse iterator to the end of the list sentinel.
 
bool isEmpty () const
 Returns true if the list is empty.
 
unsigned int size () const
 Returns the number of elements in the list.
 
void clear ()
 Clears the list.
 
const T & front () const
 Returns a constant reference to the first element in constant time.
 
T & front ()
 Returns a reference to the first element in constant time.
 
const T & back () const
 Returns a constant reference to the last element in constant time.
 
T & back ()
 Returns a reference to the last element in constant time.
 
void pushFront (const T &element)
 Inserts a new element as the first, in constant time.
 
void pushFront (T &&element)
 Move inserts a new element as the first, in constant time.
 
template<typename... Args>
void emplaceFront (Args &&... args)
 Constructs a new element as the first, in constant time.
 
void pushBack (const T &element)
 Inserts a new element as the last, in constant time.
 
void pushBack (T &&element)
 Move inserts a new element as the last, in constant time.
 
template<typename... Args>
void emplaceBack (Args &&... args)
 Constructs a new element as the last, in constant time.
 
void popFront ()
 Removes the first element in constant time.
 
void popBack ()
 Removes the last element in constant time.
 
ConstIterator insertAfter (const Iterator position, const T &element)
 Inserts a new element after the node pointed by the constant iterator.
 
ConstIterator insertAfter (const Iterator position, T &&element)
 Move inserts a new element after the node pointed by the constant iterator.
 
template<typename... Args>
ConstIterator emplaceAfter (const Iterator position, Args &&... args)
 Constructs a new element after the node pointed by the constant iterator.
 
ConstIterator insertBefore (const Iterator position, const T &element)
 Inserts a new element before the node pointed by the constant iterator.
 
ConstIterator insertBefore (const Iterator position, T &&element)
 Move inserts a new element before the node pointed by the constant iterator.
 
template<typename... Args>
ConstIterator emplaceBefore (const Iterator position, Args &&... args)
 Constructs a new element before the node pointed by the constant iterator.
 
ConstIterator insert (const Iterator position, Iterator first, const Iterator last)
 Inserts new elements from a source range after the node pointed by the constant iterator, last not included.
 
ConstIterator erase (ConstIterator position)
 Removes the node pointed by the constant iterator in constant time.
 
ConstIterator erase (ConstIterator first, const ConstIterator last)
 Removes the range of nodes pointed by the iterators in constant time.
 
void remove (const T &element)
 Removes a specified element in linear time.
 
template<class Predicate >
void removeIf (Predicate pred)
 Removes all the elements that fulfill the condition.
 
void splice (Iterator position, List &source)
 Transfers all the elements from the source list in front of position
 
void splice (Iterator position, List &source, Iterator it)
 Transfers one element at it from the source list in front of position
 
void splice (Iterator position, List &source, Iterator first, Iterator last)
 Transfers a range of elements from the source list, last not included, in front of position
 

Detailed Description

template<class T>
class nctl::List< T >

A double linked list based on templates.

Member Function Documentation

◆ erase() [1/2]

template<class T >
List< T >::ConstIterator nctl::List< T >::erase ( ConstIterator  first,
const ConstIterator  last 
)

Removes the range of nodes pointed by the iterators in constant time.

Note
The first iterator cannot be used after on.

◆ erase() [2/2]

template<class T >
List< T >::ConstIterator nctl::List< T >::erase ( ConstIterator  position)

Removes the node pointed by the constant iterator in constant time.

Note
The iterator cannot be used after on.

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