Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

List< T > Class Template Reference

The class implements double linked lists for arbitrary data types. More...

#include <List.h>

Collaboration diagram for List< T >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void clear ()
 The functions empties the list.

 List ()
 Constructor of an empty list.

Listoperator= (const List &l)
 The operator copies another list into this list.

 List (const List &l)
 Copy constuctor.

 ~List ()
 Destructor.

Pos getFirst () const
 The function returns an iterator pointing to the first element of the list.

Pos getLast () const
 The function returns an iterator pointing to the last element of the list.

const T & operator[] (Pos p) const
 The operator implements read-only access to individual elements of the list.

T & operator[] (Pos p)
 The operator implements read/write access to individual elements of the list.

List< T > & operator+= (const List< T > &l)
 The operator concatenates another list to this list.

List< T > operator+ (const List< T > &l) const
 The operator concatenates two lists.

int getSize () const
 The function returns the number of elements in the list.

Pos insert (T *t, Pos p=Pos())
 The function inserts a new element into the list.

Pos insert (const T &t, Pos p=Pos())
 The function inserts a new element into the list.

void remove (Pos &p)
 The function removes an element from the list.


Private Attributes

Datafirst
 A pointer to the first list node.

Datalast
 A pointer to the last list node.

int size
 The number of entries in the list.


Detailed Description

template<class T>
class List< T >

The class implements double linked lists for arbitrary data types.

Definition at line 22 of file List.h.


Constructor & Destructor Documentation

template<class T>
List< T >::List  )  [inline]
 

Constructor of an empty list.

Definition at line 136 of file List.h.

References List< T >::first.

template<class T>
List< T >::List const List< T > &  l  )  [inline]
 

Copy constuctor.

Parameters:
l The list from which this list will be copied.

Definition at line 160 of file List.h.

References List< T >::first.

template<class T>
List< T >::~List  )  [inline]
 

Destructor.

All list elements are destructed.

Definition at line 166 of file List.h.

References List< T >::clear().

Here is the call graph for this function:


Member Function Documentation

template<class T>
void List< T >::clear  )  [inline]
 

The functions empties the list.

All list elements are destructed.

Definition at line 126 of file List.h.

References List< T >::getFirst(), and List< T >::remove().

Referenced by List< T >::operator=(), operator>>(), and List< T >::~List().

Here is the call graph for this function:

template<class T>
List& List< T >::operator= const List< T > &  l  )  [inline]
 

The operator copies another list into this list.

The previous entries in this list are destroyed.

Parameters:
l The other list.
Returns:
A reference to this list after the operation took place.

Definition at line 144 of file List.h.

References List< T >::clear(), List< T >::getFirst(), and List< T >::insert().

Here is the call graph for this function:

template<class T>
Pos List< T >::getFirst  )  const [inline]
 

The function returns an iterator pointing to the first element of the list.

Returns:
The iterator.

Definition at line 172 of file List.h.

References List< T >::first.

Referenced by List< T >::clear(), List< T >::operator+=(), and List< T >::operator=().

template<class T>
Pos List< T >::getLast  )  const [inline]
 

The function returns an iterator pointing to the last element of the list.

Returns:
The iterator.

Definition at line 178 of file List.h.

template<class T>
const T& List< T >::operator[] Pos  p  )  const [inline]
 

The operator implements read-only access to individual elements of the list.

Parameters:
p The iterator pointing to the element to be accessed.
Returns:
A reference to the selected list element.

Definition at line 185 of file List.h.

References List< T >::Data::data, and List< T >::Pos::entry.

template<class T>
T& List< T >::operator[] Pos  p  )  [inline]
 

The operator implements read/write access to individual elements of the list.

Parameters:
p The iterator pointing to the element to be accessed.
Returns:
A reference to the selected list element.

Definition at line 192 of file List.h.

References List< T >::Data::data, and List< T >::Pos::entry.

template<class T>
List<T>& List< T >::operator+= const List< T > &  l  )  [inline]
 

The operator concatenates another list to this list.

Parameters:
l The other list.
Returns:
A reference to this list after the operation took place.

Definition at line 199 of file List.h.

References List< T >::getFirst(), and List< T >::insert().

Here is the call graph for this function:

template<class T>
List<T> List< T >::operator+ const List< T > &  l  )  const [inline]
 

The operator concatenates two lists.

Parameters:
l The other list.
Returns:
The concatenation of this list and the other list.

Definition at line 211 of file List.h.

template<class T>
int List< T >::getSize  )  const [inline]
 

The function returns the number of elements in the list.

Returns:
The length of the list.

Definition at line 217 of file List.h.

template<class T>
Pos List< T >::insert T *  t,
Pos  p = Pos()
[inline]
 

The function inserts a new element into the list.

Parameters:
t The new element. It will not be copied, and it will be destructed when it is removed from the list.
p An iterator pointing to the element after which the new one is inserted. If the operator points nowhere, the element will be appended to the list. This is also the default case.
Returns:
An iterator pointing to the new list element.

Definition at line 228 of file List.h.

References List< T >::Data::data, List< T >::Pos::entry, List< T >::first, List< T >::Data::next, and List< T >::Data::prev.

Referenced by List< T >::insert(), List< T >::operator+=(), List< T >::operator=(), and operator>>().

template<class T>
Pos List< T >::insert const T &  t,
Pos  p = Pos()
[inline]
 

The function inserts a new element into the list.

Parameters:
t The new element. A copy will be inserted into the list. Therefore, the class of the element must provide a copy constuctor.
p An iterator pointing to the element after which the new one is inserted. If the operator points nowhere, the element will be appended to the list. This is also the default case.
Returns:
An iterator pointing to the new list element.

Definition at line 270 of file List.h.

References List< T >::insert().

Here is the call graph for this function:

template<class T>
void List< T >::remove Pos p  )  [inline]
 

The function removes an element from the list.

The element will be destructed.

Parameters:
p An iterator pointing to the element that shall be removed.

Definition at line 277 of file List.h.

References List< T >::Data::data, List< T >::Pos::entry, List< T >::first, List< T >::Data::next, and List< T >::Data::prev.

Referenced by List< T >::clear().


Member Data Documentation

template<class T>
Data* List< T >::first [private]
 

A pointer to the first list node.

Definition at line 35 of file List.h.

Referenced by List< T >::getFirst(), List< T >::insert(), List< T >::List(), and List< T >::remove().

template<class T>
Data* List< T >::last [private]
 

A pointer to the last list node.

Definition at line 36 of file List.h.

template<class T>
int List< T >::size [private]
 

The number of entries in the list.

Definition at line 37 of file List.h.


The documentation for this class was generated from the following file:
Generated on Thu Sep 23 20:09:23 2004 for GT2004 by doxygen 1.3.6