PUMA Library Reference Manual
Loading...
Searching...
No Matches
Puma::List Class Reference

#include <Puma/List.h>

+ Inheritance diagram for Puma::List:

Description

Double-linked list implementation.

Public Member Functions

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

Constructor & Destructor Documentation

◆ List() [1/2]

Puma::List::List ( )
inline

Constructor.

◆ List() [2/2]

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

Copy-constructor.

Parameters
copyThe list to copy.

◆ ~List()

Puma::List::~List ( )

Destructor.

Destroys the list elements.

Member Function Documentation

◆ append()

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

Append an element to the list.

Parameters
elementThe element.

◆ clear()

void Puma::List::clear ( )

Destroy the list elements.

◆ copy()

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.

◆ cut()

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.

◆ empty()

bool Puma::List::empty ( ) const
inline

Check if the list is empty.

return True if the list is empty.

◆ first()

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

Get the first element in the list.

Returns
A pointer to the first element, or NULL if list is empty.

◆ insert()

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.

◆ kill()

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.

◆ last()

const ListElement * Puma::List::last ( ) const
inline

Get the last element in the list.

Returns
A pointer to the last element, or NULL if list is empty.

◆ move()

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.

◆ move_before()

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.

◆ next()

const ListElement * Puma::List::next ( const ListElement element) const
inline

Get the next element of the given element.

Returns
A pointer to the next element, or NULL if the given element is NULL.

◆ operator+()

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.
Returns
A new list containing the elements of both lists.

◆ operator+=()

List & Puma::List::operator+= ( const List list)

Append the given list.

Parameters
listThe list to append.
Returns
A reference to this list.

◆ operator=()

List & Puma::List::operator= ( const List copy)

Assignment operator.

Parameters
copyThe list to copy.
Returns
A reference to this list.

◆ paste()

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.

◆ paste_before()

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.

◆ prepend()

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

Prepend an element to the list.

Parameters
elementThe element.

◆ prev()

const ListElement * Puma::List::prev ( const ListElement element) const
inline

Get the previous element of the given element.

Returns
A pointer to the previous element, or NULL if the given element is NULL.

◆ remove()

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

Remove the given element from the list.

Parameters
elementThe list element.