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

lrt::List Class Template Reference

A double-linked list collection. More...

#include <rtlist.h>

List of all members.

Public Methods

 List ()
 Creates an empty list.

 List (const List< T > &)
 Creates a new list which contains a copy of all entries of the given list.

List< T > & operator= (const List< T > &)
 Clears the list, then copies all the entries from the given list over to this one.

 ~List ()
 Destroys the list and all of its elements.

T & append (const T &elem)
 Append an element to the list. More...

T & prepend (const T &elem)
 Prepend an element to the list. More...

T & insertBefore (Iterator< T > &pos, const T &elem)
 Insert an element before the given position. More...

T & insertAfter (Iterator< T > &pos, const T &elem)
 Insert an element after the given position. More...

void remove (Iterator< T > &pos)
 Remove an element from the list. More...

Node * remove (Node *element)
 Remove an element from the list. More...

void clear ()
 Remove all elements from the list, and destroy them.

int length () const
 Returns the current element count of the list.

int getSize () const
 Returns the current element count of the list.

Node * first ()
const Node * first () const
Node * last ()
const Node * last () const
Iterator< T > begin () const
 Returns an unmodifyable iterator to the first element of the list. More...

Iterator< T > end () const
 Returns an unmodifyable iterator to the last element of the list. More...

Iterator< T > begin ()
 Returns an modifyable iterator to the first element of the list. More...

Iterator< T > end ()
 Returns an modifyable iterator to the last element of the list. More...


Friends

class IteratorImpl


Detailed Description

template<class T>
class lrt::List< T >

A double-linked list collection.

As opposed to Vectors, elements can be inserted and removed very quickly into lists, and sequential access to elements (forwards and backwards) is quick, too. (The class Iterator is used for this.) However, random access to elements is quite slow.


Member Function Documentation

template<class T>
T & lrt::List< T >::append (  const T &    elem ) 
 

Append an element to the list.

Parameters:
elem  The element to append (it will be copied).
Returns:
A reference to the appended element.

template<class T>
Iterator< T > lrt::List< T >::begin (    )  [inline]
 

Returns an modifyable iterator to the first element of the list.

If the list is empty, the iterator points to nothing; you can use Iterator::hasElement() to check this.

template<class T>
Iterator< T > lrt::List< T >::begin (    )  const [inline]
 

Returns an unmodifyable iterator to the first element of the list.

If the list is empty, the iterator points to nothing; you can use Iterator::hasElement() to check this.

template<class T>
Iterator< T > lrt::List< T >::end (    )  [inline]
 

Returns an modifyable iterator to the last element of the list.

If the list is empty, the iterator points to nothing; you can use Iterator::hasElement() to check this.

template<class T>
Iterator< T > lrt::List< T >::end (    )  const [inline]
 

Returns an unmodifyable iterator to the last element of the list.

If the list is empty, the iterator points to nothing; you can use Iterator::hasElement() to check this.

template<class T>
T & lrt::List< T >::insertAfter (  Iterator< T > &    pos,
const T &    elem
) 
 

Insert an element after the given position.

Parameters:
pos  The position before the new element. If the iterator points to nothing, the new element is simply appended to the list.
elem  The element to insert (it will be copied).
Returns:
A reference to the inserted element.

template<class T>
T & lrt::List< T >::insertBefore (  Iterator< T > &    pos,
const T &    elem
) 
 

Insert an element before the given position.

Parameters:
pos  The position after the new element. If the iterator points to nothing, the new element is simply appended to the list.
elem  The element to insert (it will be copied).
Returns:
A reference to the inserted element.

template<class T>
T & lrt::List< T >::prepend (  const T &    elem ) 
 

Prepend an element to the list.

Parameters:
elem  The element to prepend (it will be copied).
Returns:
A reference to the prepended element.

template<class T>
List< T >::Node * lrt::List< T >::remove (  Node *    element ) 
 

Remove an element from the list.

Returns a pointer to the next element of the list.

template<class T>
void lrt::List< T >::remove (  Iterator< T > &    pos )  [inline]
 

Remove an element from the list.

Moves the iterator to the next element of the list.


The documentation for this class was generated from the following files:
This is the RoboTour API documentation version 0.1 • Copyright (C) by Florian Fischer