IBAMR  IBAMR version 0.19.
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Friends | List of all members
SAMRAI::tbox::List< TYPE > Class Template Reference

#include <tbox/List.h>

Inheritance diagram for SAMRAI::tbox::List< TYPE >:
Inheritance graph
[legend]

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 ()
 

Private Attributes

int d_number_items
 
ListNode< TYPE > * d_list_head
 
ListNode< TYPE > * d_list_tail
 

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

◆ Iterator

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.

Constructor & Destructor Documentation

◆ List() [1/2]

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

Create a list with no elements.

◆ List() [2/2]

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.

◆ ~List()

template<class TYPE >
virtual SAMRAI::tbox::List< TYPE >::~List ( )
virtual

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

Member Function Documentation

◆ freeCachedListItems()

template<class TYPE >
static void SAMRAI::tbox::List< TYPE >::freeCachedListItems ( )
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.

◆ operator=()

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.

◆ isEmpty()

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

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

◆ getNumberOfItems()

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

Return the number of items in the list.

◆ size()

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

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

◆ addItem()

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

Add a new item to the head of the list.

◆ addItemBefore()

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.

◆ addItemAfter()

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.

◆ appendItem()

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

Add a new item to the tail of the list.

◆ copyItems()

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.

◆ catenateItems()

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.

◆ catenateItemsAtFront()

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.

◆ clearItems()

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

Empty the list. All list items are deallocated.

◆ getFirstItem()

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

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.

◆ getLastItem()

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

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.

◆ removeFirstItem()

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

Remove (deallocate) the first item in the list.

◆ removeLastItem()

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

Remove (deallocate) the last item in the list.

◆ removeItem()

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.

◆ reverse()

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.

◆ listStart()

template<class TYPE >
List<TYPE>::Iterator SAMRAI::tbox::List< TYPE >::listStart ( ) const

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

◆ listEnd()

template<class TYPE >
List<TYPE>::Iterator SAMRAI::tbox::List< TYPE >::listEnd ( ) const

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

Friends And Related Function Documentation

◆ ListIterator< TYPE >

template<class TYPE >
friend class ListIterator< TYPE >
friend

Member Data Documentation

◆ d_number_items

template<class TYPE >
int SAMRAI::tbox::List< TYPE >::d_number_items
private

◆ d_list_head

template<class TYPE >
ListNode<TYPE>* SAMRAI::tbox::List< TYPE >::d_list_head
private

◆ d_list_tail

template<class TYPE >
ListNode<TYPE>* SAMRAI::tbox::List< TYPE >::d_list_tail
private

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