Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PP_List< T > Class Template Reference

A Doubly-Linked List for ParmParse. More...

#include <ParmParse.H>

Inheritance diagram for PP_List< T >:

Inheritance graph
[legend]
Collaboration diagram for PP_List< T >:

Collaboration graph
[legend]
List of all members.

Public Methods

 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)
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
bool operator== (const PP_List< T > &rhs) const
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)
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)
void addBefore (PP_ListIterator< T > &lit, const T &val)
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>.


Protected Methods

void remove (PP_ListLink< T > *ln)
PP_ListLink< T > * addBefore (PP_ListLink< T > *ln, const T &val)
PP_ListLink< T > * addAfter (PP_ListLink< T > *ln, const T &val)

Protected Attributes

PP_ListLink< T > * head
PP_ListLink< T > * tail

Friends

class PP_ListIterator< T >

Detailed Description

template<class T>
class PP_List< T >

A Doubly-Linked List for ParmParse.

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.


Constructor & Destructor Documentation

template<class T>
PP_List< T >::PP_List   [inline]
 

: Construct an empty PP_List<T>.

template<class T>
PP_List< T >::PP_List const PP_List< T > &    rhs [inline]
 

: The copy constructor.

template<class T>
PP_List< T >::~PP_List   [inline]
 

: The destructor.


Member Function Documentation

template<class T>
void PP_List< T >::add const T &    value [inline]
 

: Adds a copy of the value to the end of the PP_List<T>.

template<class T>
PP_ListLink< T > * PP_List< T >::addAfter PP_ListLink< T > *    ln,
const T &    val
[inline, protected]
 

template<class T>
void PP_List< T >::addAfter PP_ListIterator< T > &    lit,
const T &    val
[inline]
 

: Insert val into PP_List<T> after the object pointed to by PP_ListIterator<T>.

template<class T>
PP_ListLink< T > * PP_List< T >::addBefore PP_ListLink< T > *    ln,
const T &    val
[inline, protected]
 

template<class T>
void PP_List< T >::addBefore PP_ListIterator< T > &    lit,
const T &    val
[inline]
 

: Insert val into PP_List<T> before the object pointed to by PP_ListIterator<T>.

template<class T>
void PP_List< T >::append const T &    value [inline]
 

: Adds a copy of the value to the end of the PP_List<T>.

template<class T>
void PP_List< T >::catenate PP_List< T > &    src [inline]
 

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

template<class T>
void PP_List< T >::clear   [inline]
 

: Removes all objects from the PP_List<T>.

template<class T>
PP_ListIterator< T > PP_List< T >::first   const [inline]
 

: Returns a PP_ListIterator<T> to the first object in this PP_List<T>.

template<class T>
T & PP_List< T >::firstElement   const [inline]
 

: Returns a reference to the first element in the PP_List<T>.

template<class T>
bool PP_List< T >::includes const T &    value const [inline]
 

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

template<class T>
bool PP_List< T >::isEmpty   const [inline]
 

: Returns true if the PP_List<T> is empty.

template<class T>
bool PP_List< T >::isNotEmpty   const [inline]
 

: Returns true if the PP_List<T> is not empty.

template<class T>
void PP_List< T >::join const PP_List< T > &    src [inline]
 

: Appends a copy of all items in PP_List<T> src to this PP_List<T>.

template<class T>
PP_ListIterator< T > PP_List< T >::last   const [inline]
 

: Returns a PP_ListIterator<T> to the last object in this PP_List<T>.

template<class T>
T & PP_List< T >::lastElement   const [inline]
 

: Returns a reference to the last element in the PP_List<T>.

template<class T>
int PP_List< T >::length   const [inline]
 

: Returns the number of objects in the PP_List<T>.

template<class T>
bool PP_List< T >::operator!= const PP_List< T > &    rhs const [inline]
 

: Returns true if the this and rhs are not equal.

template<class T>
PP_List< T > & PP_List< T >::operator= const PP_List< T > &    rhs [inline]
 

: The assignment operator.

template<class T>
bool PP_List< T >::operator== const PP_List< T > &    rhs const [inline]
 

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

template<class T>
T & PP_List< T >::operator[] const PP_ListIterator< T > &    li [inline]
 

: Returns reference to object pointed to by the PP_ListIterator<T>.

template<class T>
const T & PP_List< T >::operator[] const PP_ListIterator< T > &    li const [inline]
 

: Returns reference to object pointed to by the PP_ListIterator<T>.

template<class T>
void PP_List< T >::prepend const T &    value [inline]
 

: Adds a copy of the value to the beginning of the PP_List<T>.

template<class T>
void PP_List< T >::remove PP_ListLink< T > *    ln [inline, protected]
 

template<class T>
void PP_List< T >::remove PP_ListIterator< T > &    lit [inline]
 

: Removes the object pointed to by the PP_ListIterator<T>.

template<class T>
void PP_List< T >::remove const PP_List< T > &    lst [inline]
 

: Removes all objects in the PP_List<T> equal to any of the values in lst.

template<class T>
void PP_List< T >::remove const T &    value [inline]
 

: Removes all objects in the PP_List<T> equal to value.

template<class T>
void PP_List< T >::removeFirst   [inline]
 

: Removes the first element in the PP_List<T>.

template<class T>
void PP_List< T >::removeLast   [inline]
 

: Removes the last element in the PP_List<T>.

template<class T>
void PP_List< T >::replace PP_ListIterator< T > &    li,
const T &    val
[inline]
 

: Replace the value pointed to by the PP_ListIterator<T> by val.


Friends And Related Function Documentation

template<class T>
friend class PP_ListIterator< T > [friend]
 


Member Data Documentation

template<class T>
PP_ListLink<T>* PP_List< T >::head [protected]
 

template<class T>
PP_ListLink<T>* PP_List< T >::tail [protected]
 


The documentation for this class was generated from the following file:
Generated on Wed Jan 19 17:56:31 2005 for Chombo&INSwithParticles by doxygen1.2.16