SAMRAI::tbox::List< TYPE > Class Template Reference

#include <source/toolbox/base/List.h>

Inheritance diagram for SAMRAI::tbox::List< TYPE >:

Inheritance graph
[legend]
List of all members.

Public Types

typedef ListIterator< TYPE > Iterator

Public Member Functions

 List ()
 List (const List< TYPE > &list)
List< TYPE > & operator= (const List< TYPE > &list)
virtual ~List ()
bool isEmpty () const
int getNumberOfItems () const
int size () const
void addItem (const TYPE &item)
void addItemBefore (ListIterator< TYPE > &iter, const TYPE &item)
void addItemAfter (ListIterator< TYPE > &iter, const TYPE &item)
void appendItem (const TYPE &item)
void copyItems (const List< TYPE > &list)
void catenateItems (List< TYPE > &list)
void catenateItemsAtFront (List< TYPE > &list)
void clearItems ()
TYPE & getFirstItem () const
TYPE & getLastItem () const
void removeFirstItem ()
void removeLastItem ()
void removeItem (ListIterator< TYPE > &iter)
void reverse ()
List< TYPE >::Iterator listStart () const
List< TYPE >::Iterator listEnd () const

Static Public Member Functions

static void freeCachedListItems ()

Friends

class ListIterator< TYPE >

Detailed Description

template<class TYPE>
class SAMRAI::tbox::List< TYPE >

Class List is a template-based doubly-linked list container. It is simpler that the STL List class, which is not yet delivered with all compilers. In the future this class may be replaced with the STL version.

The List item in the list must define the assignment operator "=" and the default const copy constructor. This list implementation uses copy to add the list item to the linked list. If this is too expensive for the object to be placed in the list, then a smart pointer to the object should be used instead.


Member Typedef Documentation

template<class TYPE>
typedef ListIterator<TYPE> SAMRAI::tbox::List< TYPE >::Iterator

The iterator for class List. Because of problems with some compilers and nested templates, the iterator for List is a separate class called ListIterator<TYPE> that is typedef-ed to List<TYPE>::Iterator. Use the List<TYPE>::Iterator form, since the other form may disappear as compilers get better and can accept nested template classes.

Reimplemented in SAMRAI::hier::BoxList< DIM >.


Constructor & Destructor Documentation

template<class TYPE>
SAMRAI::tbox::List< TYPE >::List (  )  [inline]

Create a list with no elements.

template<class TYPE>
SAMRAI::tbox::List< TYPE >::List ( const List< TYPE > &  list  ) 

The const constructor copies list items from the source list to the newly constructed list. The source list is not modified.

template<class TYPE>
SAMRAI::tbox::List< TYPE >::~List (  )  [inline, virtual]

Deallocate a list. If items remain in the list, they are deallocated.


Member Function Documentation

template<class TYPE>
void SAMRAI::tbox::List< TYPE >::freeCachedListItems (  )  [inline, static]

Free cached list nodes. A cached list of list nodes is used to speed allocation and deallocation of list items. This call will return this cached memory to the free memory pool.

template<class TYPE>
List< TYPE > & SAMRAI::tbox::List< TYPE >::operator= ( const List< TYPE > &  list  ) 

The assignment operator copies the values from the right hand side list into the list on the left side of the equals sign. The source list is not modified. All previous values in the destination list are lost.

template<class TYPE>
bool SAMRAI::tbox::List< TYPE >::isEmpty (  )  const [inline]

Check whether a list is empty (has no elements).

template<class TYPE>
int SAMRAI::tbox::List< TYPE >::getNumberOfItems (  )  const [inline]

Return the number of items in the list.

template<class TYPE>
int SAMRAI::tbox::List< TYPE >::size (  )  const [inline]

Return the number of items in the list. Identical to getNumberOfItems(), but this method is common to several container classes.

template<class TYPE>
void SAMRAI::tbox::List< TYPE >::addItem ( const TYPE &  item  ) 

Add a new item to the head of the list.

template<class TYPE>
void SAMRAI::tbox::List< TYPE >::addItemBefore ( ListIterator< TYPE > &  iter,
const TYPE &  item 
)

Add a new item to the list before the item pointed to by the specified iterator.

template<class TYPE>
void SAMRAI::tbox::List< TYPE >::addItemAfter ( ListIterator< TYPE > &  iter,
const TYPE &  item 
)

Add a new item to the list after the item pointed to by the specified iterator.

template<class TYPE>
void SAMRAI::tbox::List< TYPE >::appendItem ( const TYPE &  item  ) 

Add a new item to the tail of the list.

template<class TYPE>
void SAMRAI::tbox::List< TYPE >::copyItems ( const List< TYPE > &  list  ) 

Copy list items from the argument list. The new items are appended to the end of the current list. The argument list is not modified.

template<class TYPE>
void SAMRAI::tbox::List< TYPE >::catenateItems ( List< TYPE > &  list  ) 

Catenate list items from the argument list to the end of the current list. Unline copyItems(), the argument list is set to null.

template<class TYPE>
void SAMRAI::tbox::List< TYPE >::catenateItemsAtFront ( List< TYPE > &  list  ) 

Catenate list items from the argument list to the front of the current list. Unline copyItems(), the argument list is set to null.

template<class TYPE>
void SAMRAI::tbox::List< TYPE >::clearItems (  ) 

Empty the list. All list items are deallocated.

template<class TYPE>
TYPE & SAMRAI::tbox::List< TYPE >::getFirstItem (  )  const [inline]

Return a reference to the first item in the list. This operation is not defined if the list is empty. This member function is const since it cannot change the list, although the item in the list may change.

template<class TYPE>
TYPE & SAMRAI::tbox::List< TYPE >::getLastItem (  )  const [inline]

Return a reference to the last item in the list. This operation is not defined if the list is empty. This member function is const since it cannot change the list, although the item in the list may change.

template<class TYPE>
void SAMRAI::tbox::List< TYPE >::removeFirstItem (  ) 

Remove (deallocate) the first item in the list.

template<class TYPE>
void SAMRAI::tbox::List< TYPE >::removeLastItem (  ) 

Remove (deallocate) the last item in the list.

template<class TYPE>
void SAMRAI::tbox::List< TYPE >::removeItem ( ListIterator< TYPE > &  iter  ) 

Remove (deallocate) the item pointed to by the iterator. After performing the remove, the iterator becomes invalid. Iterators that point to other elements in the list remain valid after the deletion of an item.

template<class TYPE>
void SAMRAI::tbox::List< TYPE >::reverse (  ) 

Reverse all elements in the list. This operation is performed in-place by swapping next and previous list element pointers.

template<class TYPE>
ListIterator< TYPE > SAMRAI::tbox::List< TYPE >::listStart (  )  const [inline]

Return a List<TYPE>::Iterator that points to the start of the list.

template<class TYPE>
ListIterator< TYPE > SAMRAI::tbox::List< TYPE >::listEnd (  )  const [inline]

Return a List<TYPE>::Iterator that points to the end of the list.


Friends And Related Function Documentation

template<class TYPE>
friend class ListIterator< TYPE > [friend]


The documentation for this class was generated from the following files:
Generated on Thu Jun 18 11:28:58 2009 for SAMRAI by  doxygen 1.5.1