Simpatico
v1.10
|
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.
#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... | |
Util::List< Data >::List | ( | ) |
|
inlinevirtual |
Destructor (does nothing).
Definition at line 45 of file List.h.
References Util::List< Data >::begin(), Util::List< Data >::capacity(), Util::List< Data >::initialize(), Util::List< Data >::insert(), Util::List< Data >::insertNext(), Util::List< Data >::insertPrev(), Util::List< Data >::isValid(), Util::List< Data >::popBack(), Util::List< Data >::popFront(), Util::List< Data >::pushBack(), Util::List< Data >::pushFront(), and Util::List< Data >::size().
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.
References Util::List< Data >::capacity().
Referenced by Util::List< Data >::~List().
|
inline |
Get the number of elements.
Definition at line 217 of file List.h.
Referenced by Util::List< Data >::~List().
|
inline |
Get capacity of the array.
Definition at line 224 of file List.h.
Referenced by Util::List< Data >::initialize(), and Util::List< Data >::~List().
void Util::List< Data >::pushBack | ( | Node< Data > & | node | ) |
Push a node onto the the back of the List.
node | Node object from associated node array. |
Definition at line 231 of file List.h.
References Util::Node< Data >::setList(), and Util::Node< Data >::setNext().
Referenced by Util::List< Data >::~List().
void Util::List< Data >::pushFront | ( | Node< Data > & | node | ) |
Push a node onto the the front of the List.
node | Node object from associated node array. |
Definition at line 251 of file List.h.
References Util::Node< Data >::setList(), and Util::Node< Data >::setPrev().
Referenced by Util::List< Data >::~List().
Node< Data > & Util::List< Data >::popBack | ( | ) |
Remove a node from the back of the list.
Definition at line 273 of file List.h.
References Util::Node< Data >::clear(), Util::Node< Data >::prev(), and UTIL_THROW.
Referenced by Util::List< Data >::~List().
Node< Data > & Util::List< Data >::popFront | ( | ) |
Remove a node from the front of the list.
Definition at line 298 of file List.h.
References Util::Node< Data >::clear(), Util::Node< Data >::next(), and UTIL_THROW.
Referenced by Util::List< Data >::~List().
void Util::List< Data >::insertNext | ( | Node< Data > & | node, |
Node< Data > & | newNode | ||
) |
Insert newNode into list after node.
node | Node in the existing list. |
newNode | new 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().
Referenced by Util::List< Data >::~List().
void Util::List< Data >::insertPrev | ( | Node< Data > & | node, |
Node< Data > & | newNode | ||
) |
Insert newNode into list before node.
Definition at line 340 of file List.h.
References Util::Node< Data >::attachPrev(), Util::Node< Data >::prev(), and Util::Node< Data >::setPrev().
Referenced by Util::List< Data >::~List().
void Util::List< Data >::insert | ( | Node< Data > & | node | ) |
Insert node into list in sequential order.
node | Node 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 >::setList(), Util::Node< Data >::setNext(), and Util::Node< Data >::setPrev().
Referenced by Util::List< Data >::~List().
void Util::List< Data >::remove | ( | Node< Data > & | node | ) |
Remove node from list.
node | Node 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().
void Util::List< Data >::begin | ( | ListIterator< Data > & | iterator | ) | const |
Set an iterator to the front of this List.
iterator | ListIterator, initialized on output. |
Definition at line 449 of file List.h.
References Util::ListIterator< Data >::setCurrent().
Referenced by Util::ListIterator< Data >::ListIterator(), and Util::List< Data >::~List().
bool Util::List< Data >::isValid | ( | ) | const |
Check validity of linked list.
Definition at line 459 of file List.h.
References Util::Node< Data >::list(), Util::Node< Data >::next(), Util::Node< Data >::prev(), and UTIL_THROW.
Referenced by Util::List< Data >::~List().