PSCF v1.1
Public Member Functions | List of all members
Util::List< Data > Class Template Reference

Linked list class template. More...

#include <List.h>

Public Member Functions

 List ()
 Default constructor. More...
 
virtual ~List ()
 Destructor (does nothing). More...
 
void initialize (Node< Data > *nodes, int capacity)
 Provide an array of Node<Data> objects for this List. More...
 
int size () const
 Get the number of elements. More...
 
int capacity () const
 Get capacity of the array. More...
 
void pushBack (Node< Data > &node)
 Push a node onto the the back of the List. More...
 
void pushFront (Node< Data > &node)
 Push a node onto the the front of the List. More...
 
Node< Data > & popBack ()
 Remove a node from the back of the list. More...
 
Node< Data > & popFront ()
 Remove a node from the front of the list. More...
 
void insertNext (Node< Data > &node, Node< Data > &newNode)
 Insert newNode into list after node. More...
 
void insertPrev (Node< Data > &node, Node< Data > &newNode)
 Insert newNode into list before node. More...
 
void insert (Node< Data > &node)
 Insert node into list in sequential order. More...
 
void remove (Node< Data > &node)
 Remove node from list. More...
 
void begin (ListIterator< Data > &iterator) const
 Set an iterator to the front of this List. More...
 
bool isValid () const
 Check validity of linked list. More...
 

Detailed Description

template<typename Data>
class Util::List< Data >

Linked list class template.

This list implementation is based on an underlying C array of Node<Data> objects. This array may be used by several List objects, and so must be allocated outside the Link class and provided via the initialize method.

Definition at line 32 of file List.h.

Constructor & Destructor Documentation

◆ List()

template<typename Data >
Util::List< Data >::List

Default constructor.

Definition at line 192 of file List.h.

◆ ~List()

template<typename Data >
virtual Util::List< Data >::~List ( )
inlinevirtual

Destructor (does nothing).

Definition at line 45 of file List.h.

Member Function Documentation

◆ initialize()

template<typename Data >
void Util::List< Data >::initialize ( Node< Data > *  nodes,
int  capacity 
)

Provide an array of Node<Data> objects for this List.

Definition at line 206 of file List.h.

◆ size()

template<typename Data >
int Util::List< Data >::size
inline

Get the number of elements.

Returns
Number of elements in this list.

Definition at line 217 of file List.h.

Referenced by pscfpp.file.File::__eq__(), pscfpp.text.Record::__init__(), pscfpp.file.File::__init__(), pscfpp.file.File::__repr__(), and pscfpp.text.Record::__str__().

◆ capacity()

template<typename Data >
int Util::List< Data >::capacity
inline

Get capacity of the array.

Returns
Number of elements allocated in the associated arrays.

Definition at line 224 of file List.h.

◆ pushBack()

template<typename Data >
void Util::List< Data >::pushBack ( Node< Data > &  node)

Push a node onto the the back of the List.

Parameters
nodeNode object from associated node array.

Definition at line 231 of file List.h.

References Util::Node< Data >::attachNext(), Util::Node< Data >::setList(), and Util::Node< Data >::setNext().

◆ pushFront()

template<typename Data >
void Util::List< Data >::pushFront ( Node< Data > &  node)

Push a node onto the the front of the List.

Parameters
nodeNode object from associated node array.

Definition at line 251 of file List.h.

References Util::Node< Data >::attachPrev(), Util::Node< Data >::setList(), and Util::Node< Data >::setPrev().

◆ popBack()

template<typename Data >
Node< Data > & Util::List< Data >::popBack

Remove a node from the back of the list.

Returns
Node that was removed from this list.

Definition at line 273 of file List.h.

References Util::Node< Data >::clear(), Util::Node< Data >::prev(), and UTIL_THROW.

◆ popFront()

template<typename Data >
Node< Data > & Util::List< Data >::popFront

Remove a node from the front of the list.

Returns
Node that was removed from this list.

Definition at line 298 of file List.h.

References Util::Node< Data >::clear(), Util::Node< Data >::next(), and UTIL_THROW.

◆ insertNext()

template<typename Data >
void Util::List< Data >::insertNext ( Node< Data > &  node,
Node< Data > &  newNode 
)

Insert newNode into list after node.

Parameters
nodeNode in the existing list.
newNodenew node, to be inserted as the next after node.

Definition at line 323 of file List.h.

References Util::Node< Data >::attachNext(), Util::Node< Data >::next(), and Util::Node< Data >::setNext().

◆ insertPrev()

template<typename Data >
void Util::List< Data >::insertPrev ( Node< Data > &  node,
Node< Data > &  newNode 
)

Insert newNode into list before node.

Parameters
nodeNode in the existing list.
newNodenew Node, to be inserted previous to node.

Definition at line 340 of file List.h.

References Util::Node< Data >::attachPrev(), Util::Node< Data >::prev(), and Util::Node< Data >::setPrev().

◆ insert()

template<typename Data >
void Util::List< Data >::insert ( Node< Data > &  node)

Insert node into list in sequential order.

Parameters
nodeNode to be inserted into the list.

Definition at line 386 of file List.h.

References Util::Node< Data >::attachNext(), Util::Node< Data >::list(), Util::Node< Data >::next(), Util::Node< Data >::prev(), Util::Node< Data >::setList(), Util::Node< Data >::setNext(), and Util::Node< Data >::setPrev().

◆ remove()

template<typename Data >
void Util::List< Data >::remove ( Node< Data > &  node)

Remove node from list.

Parameters
nodeNode to be removed from the list.

Definition at line 357 of file List.h.

References Util::Node< Data >::clear(), Util::Node< Data >::list(), Util::Node< Data >::next(), and Util::Node< Data >::prev().

◆ begin()

template<typename Data >
void Util::List< Data >::begin ( ListIterator< Data > &  iterator) const

Set an iterator to the front of this List.

Parameters
iteratorListIterator, initialized on output.

Definition at line 449 of file List.h.

References Util::ListIterator< Data >::setCurrent().

Referenced by Util::ListIterator< Data >::ListIterator().

◆ isValid()

template<typename Data >
bool Util::List< Data >::isValid

Check validity of linked list.

Returns
true if the list is valid, false otherwise.

Definition at line 459 of file List.h.

References Util::Node< Data >::list(), Util::Node< Data >::next(), Util::Node< Data >::prev(), and UTIL_THROW.


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