template <class T> class PP_List

A Doubly-Linked List for ParmParse

Inheritance:

PP_List


public members:

PP_List ()
PP_List (const PP_List<T>& rhs)
PP_List<T>& operator= (const PP_List<T>& rhs)
~PP_List()
void prepend (const T& value)
void append (const T& value)
void add (const T& value)
void join (const PP_List<T>& src)
void catenate (PP_List<T>& src)
void clear ()
T& firstElement () const
T& lastElement () const
bool includes (const T& value) const
bool operator== (const PP_List<T>& rhs) const
bool operator!= (const PP_List<T>& rhs) const
bool isEmpty () const
bool isNotEmpty () const
int length () const
void removeFirst ()
void removeLast ()
const T& operator[] (const PP_ListIterator<T>& li) const
T& operator[] (const PP_ListIterator<T>& li)
void remove (const T& value)
void remove (const PP_List<T>& lst)
void remove (PP_ListIterator<T>& lit)
void replace (PP_ListIterator<T>& li, const T& val)
void addAfter (PP_ListIterator<T>& lit, const T& val)
void addBefore (PP_ListIterator<T>& lit, const T& val)
PP_ListIterator<T> first () const
PP_ListIterator<T> last () const

Documentation

The PP_List<T> class is a template class that implements a doubly-linked list of objects. A PP_List<T> is a useful container class when the number of objects in the collection is not known ahead of time. A PP_List<T> can contain an arbitrary number of elements; operations such as insertion, deletion, and catenation are easily implemented and inexpensive.

The only difficulty when defining a list class is devising a mechanism to access the elements. In an array, an element is accessed using an integer index. Since the elements in a PP_List<T> are ordered by position, we could define an integer indexing operation that walks along the PP_List<T> links from the beginning until the numbered element is found. Unfortunately, this would be very inefficient when accessing elements near the end of a long list. Another solution is to allow user access to the individual link objects that contain the element as well as the forward and backward pointers. This is not a satisfactory solution since it allows user access to the internal representation of the class. The solution chosen is to define a PP_ListIterator<T> template class.

Think of a PP_ListIterator<T> as a pointer to an object in the PP_List<T>. You can access the element currently pointed to by the iterator, move the iterator forward and backward through the PP_List<T>, and use it as a mechanism to define where elements should be inserted and deleted. If the iterator is moved off the end of the list it behaves as a null pointer.

This is a concrete class, not a polymorphic one.

This is a convenience class for ParmParse and will not be in any way supported by anyone at ANAG.

PP_List ()
Construct an empty PP_List<T>.

PP_List (const PP_List<T>& rhs)
The copy constructor.

PP_List<T>& operator= (const PP_List<T>& rhs)
The assignment operator.

~PP_List ()
The destructor.

void prepend (const T& value)
Adds a copy of the value to the beginning of the PP_List<T>.

void append (const T& value)
Adds a copy of the value to the end of the PP_List<T>.

void add (const T& value)
Adds a copy of the value to the end of the PP_List<T>.

void join (const PP_List<T>& src)
Appends a copy of all items in PP_List<T> src to this PP_List<T>.

void catenate (PP_List<T>& src)
Appends a copy of all items in PP_List<T> src to this PP_List<T>. This differs from join() in that it unlinks the objects from the PP_List<T> src and glues them to the end of this PP_List<T>, leaving PP_List<T> src empty. This is more efficient that join() if src is no longer needed.

void clear ()
Removes all objects from the PP_List<T>.

T& firstElement () const
Returns a reference to the first element in the PP_List<T>.

T& lastElement () const
Returns a reference to the last element in the PP_List<T>.

bool includes (const T& value) const
Returns true if the PP_List<T> contains an object identical to value. Type T must have an operator==() defined, or be an intrinsic type.

bool operator== (const PP_List<T>& rhs) const
Returns true if the this and rhs are memberwise equal; i.e. the two lists are the same size and each of the elements in the list compare equal. Type T must have an operator==() defined, or be an intrinsic type.

bool operator!= (const PP_List<T>& rhs) const
Returns true if the this and rhs are not equal.

bool isEmpty () const
Returns true if the PP_List<T> is empty.

bool isNotEmpty () const
Returns true if the PP_List<T> is not empty.

int length () const
Returns the number of objects in the PP_List<T>.

void removeFirst ()
Removes the first element in the PP_List<T>.

void removeLast ()
Removes the last element in the PP_List<T>.

const T& operator[] (const PP_ListIterator<T>& li) const
Returns reference to object pointed to by the PP_ListIterator<T>.

T& operator[] (const PP_ListIterator<T>& li)
Returns reference to object pointed to by the PP_ListIterator<T>.

void remove (const T& value)
Removes all objects in the PP_List<T> equal to value.

void remove (const PP_List<T>& lst)
Removes all objects in the PP_List<T> equal to any of the values in lst.

void remove (PP_ListIterator<T>& lit)
Removes the object pointed to by the PP_ListIterator<T>.

void replace (PP_ListIterator<T>& li, const T& val)
Replace the value pointed to by the PP_ListIterator<T> by val.

void addAfter (PP_ListIterator<T>& lit, const T& val)
Insert val into PP_List<T> after the object pointed to by PP_ListIterator<T>.

void addBefore (PP_ListIterator<T>& lit, const T& val)
Insert val into PP_List<T> before the object pointed to by PP_ListIterator<T>.

PP_ListIterator<T> first () const
Returns a PP_ListIterator<T> to the first object in this PP_List<T>.

PP_ListIterator<T> last () const
Returns a PP_ListIterator<T> to the last object in this PP_List<T>.


this class has no child classes.

alphabetic index hierarchy of classes


Chombo

Copyright Notice

This software is copyright (C) by the Lawrence Berkeley National Laboratory. Permission is granted to reproduce this software for non-commercial purposes provided that this notice is left intact.

It is acknowledged that the U.S. Government has rights to this software under Contract DE-AC03-765F00098 between the U.S. Department of Energy and the University of California.

This software is provided as a professional and academic contribution for joint exchange. Thus it is experimental, is provided ``as is'', with no warranties of any kind whatsoever, no support, no promise of updates, or printed documentation. By using this software, you acknowledge that the Lawrence Berkeley National Laboratory and Regents of the University of California shall have no liability with respect to the infringement of other copyrights by any part of this software.