Puma Reference Manual Puma::List Class Reference



Puma::List Class Reference

Double-linked list implementation. More...

#include <Puma/List.h>

Inheritance diagram for Puma::List:
Inheritance graph

List of all members.

Public Member Functions

 List ()
 Constructor.
 List (const List &copy)
 Copy-constructor.
 ~List ()
 Destructor.
Listoperator= (const List &copy)
 Assignment operator.
Listoperator+= (const List &list)
 Append the given list.
List operator+ (const List &list)
 Create a new list containing the elements of this list followed by the elements of the given list.
void clear ()
 Destroy the list elements.
void append (ListElement &element)
 Append an element to the list.
void prepend (ListElement &element)
 Prepend an element to the list.
void insert (ListElement *at, ListElement &element)
 Insert an element at the given list position.
void remove (ListElement *element)
 Remove the given element from the list.
void kill (ListElement *from, ListElement *to=(ListElement *) 0)
 Remove and destroy all elements between the given list elements.
void cut (List &out, ListElement *from, ListElement *to=(ListElement *) 0)
 Cut all elements between the given list elements.
Listcopy (ListElement *from=(ListElement *) 0, ListElement *to=(ListElement *) 0)
 Copy all elements between the given list elements.
void paste (ListElement *at, const List &l)
 Insert copies of the elements of the given list at the given list position.
void paste_before (ListElement *at, const List &l)
 Insert copies of the elements of the given list before the given list position.
void move (ListElement *at, List &l)
 Insert the elements of the given list at the given list position.
void move_before (ListElement *at, List &l)
 Insert the elements of the given list before the given list position.
bool empty () const
 Check if the list is empty.
const ListElementfirst () const
 Get the first element in the list.
const ListElementlast () const
 Get the last element in the list.
const ListElementnext (const ListElement *element) const
 Get the next element of the given element.
const ListElementprev (const ListElement *element) const
 Get the previous element of the given element.

Detailed Description

Double-linked list implementation.


Constructor & Destructor Documentation

Puma::List::List ( ) [inline]

Constructor.

Puma::List::List ( const List copy)

Copy-constructor.

Parameters:
copyThe list to copy.

Destructor.

Destroys the list elements.


Member Function Documentation

void Puma::List::append ( ListElement element)

Append an element to the list.

Parameters:
elementThe element.

Destroy the list elements.

List* Puma::List::copy ( ListElement from = (ListElement *) 0,
ListElement to = (ListElement *) 0 
)

Copy all elements between the given list elements.

Parameters:
fromThe first list element to cut.
toThe last list element to cut.
Returns:
A new list containing the copied elements.
void Puma::List::cut ( List out,
ListElement from,
ListElement to = (ListElement *) 0 
)

Cut all elements between the given list elements.

Parameters:
outThe container for the cutted elements (are appended).
fromThe first list element to cut.
toThe last list element to cut.
bool Puma::List::empty ( ) const [inline]

Check if the list is empty.

const ListElement* Puma::List::first ( ) const [inline]

Get the first element in the list.

Returns:
The element or NULL if list is empty.

Reimplemented in Puma::Unit.

void Puma::List::insert ( ListElement at,
ListElement element 
)

Insert an element at the given list position.

Parameters:
atA list element where to insert the element.
elementThe element.
void Puma::List::kill ( ListElement from,
ListElement to = (ListElement*)0 
) [inline]

Remove and destroy all elements between the given list elements.

Parameters:
fromThe first list element to kill.
toThe last list element to kill.
const ListElement* Puma::List::last ( ) const [inline]

Get the last element in the list.

Returns:
The element or NULL if list is empty.

Reimplemented in Puma::Unit.

void Puma::List::move ( ListElement at,
List l 
)

Insert the elements of the given list at the given list position.

The elements are removed from the source list.

Parameters:
atThe list element at which to insert the list elements.
lThe list containing the elements to insert.
void Puma::List::move_before ( ListElement at,
List l 
)

Insert the elements of the given list before the given list position.

The elements are removed from the source list.

Parameters:
atThe list element before which to insert the list elements.
lThe list containing the elements to insert.
const ListElement* Puma::List::next ( const ListElement element) const [inline]

Get the next element of the given element.

Returns:
The element or NULL if the given element is NULL.
List Puma::List::operator+ ( const List list)

Create a new list containing the elements of this list followed by the elements of the given list.

Parameters:
listThe other list.
List& Puma::List::operator+= ( const List list)

Append the given list.

Parameters:
listThe list to append.
List& Puma::List::operator= ( const List copy)

Assignment operator.

Parameters:
copyThe list to copy.
void Puma::List::paste ( ListElement at,
const List l 
)

Insert copies of the elements of the given list at the given list position.

Parameters:
atThe list element at which to paste the list elements.
lThe list containing the elements to paste.
void Puma::List::paste_before ( ListElement at,
const List l 
)

Insert copies of the elements of the given list before the given list position.

Parameters:
atThe list element before which to paste the list elements.
lThe list containing the elements to paste.
void Puma::List::prepend ( ListElement element)

Prepend an element to the list.

Parameters:
elementThe element.
const ListElement* Puma::List::prev ( const ListElement element) const [inline]

Get the previous element of the given element.

Returns:
The element or NULL if the given element is NULL.
void Puma::List::remove ( ListElement element)

Remove the given element from the list.

Parameters:
elementThe list element.