Gel2D - The free/open source game creation suite

Public Member Functions
gel::GelLinkedList< dType > Class Template Reference

Doubly-linked list template. More...

#include <gelLinkedList.h>

Inheritance diagram for gel::GelLinkedList< dType >:
gel::GelQueue< dType > gel::GelStack< dType >

List of all members.

Public Member Functions

 GelLinkedList ()
 Default constructor.
 GelLinkedList (const GelLinkedList< dType > &list)
 Copy constructor.
 ~GelLinkedList ()
 Destructor.
void append (const dType &newData)
 Inserts an item at the end of the list.
void prepend (const dType &newData)
 Inserts an item at the beginning of the list.
void insert (int i, const dType &newData)
 Inserts an item at the specified index.
void removeFirst ()
 Removes the first item in the list.
void removeLast ()
 Removes the last item in the list.
void remove (int i)
 Removes the item at the specified index.
int removeAll (dType val)
 Removes all occurences of the specified value.
void replace (int i, const dType &newData)
 Replaces the item at the specified index with a new value.
dType & getFirst ()
 Gets a reference to the first item in the list.
const dType & getFirst () const
 Gets a reference to the first item in the list.
dType & getLast ()
 Gets a reference to the last item in the list.
const dType & getLast () const
 Gets a reference to the last item in the list.
dType & getItem (int i)
 Gets a reference to the item at the specified index.
const dType & getItem (int i) const
 Gets a reference to the item at the specified index.
dType takeFirst ()
 Removes the first item in the list and returns it.
dType takeLast ()
 Removes the last item in the list and returns it.
dType takeItem (int i)
 Removes the item at the specified index and returns it.
void reverse ()
 Reverses the order of the items in the list.
int countAll (dType val)
 Counts the number of occurences of the specified value.
int getSize ()
 Gets the number of items in the list.
void clear ()
 Removes all of the items from the list.
bool isMember (const dType &val)
 Checks if the specified value exists in the list.
bool isEmpty ()
 Determines whether or not the list is empty.
GelLinkedList< dType > & operator= (const GelLinkedList< dType > &l)
 Assigns a list to this list.
GelLinkedList< dType > & operator+= (const GelLinkedList< dType > &l)
 Appends all items from a list to this list.
dType & operator[] (int i)
 Gets a reference to the item at the specified index.
const dType & operator[] (int i) const
 Gets a reference to the item at the specified index.

Detailed Description

template<class dType>
class gel::GelLinkedList< dType >

Doubly-linked list template.

A few notes about indexes:
1. The list's index begins at zero.
2. You will be required to specify the index of an item in many of the following functions. The index must be in the range of 0 through getSize()-1. If you specify an index less than zero, the first item in the list will be used. Similarly, if you specify an index greater than getSize()-1 (the last item), the last item in the list will be used.


Constructor & Destructor Documentation

template<class dType>
gel::GelLinkedList< dType >::GelLinkedList ( ) [inline]

Default constructor.

Constructs an empty list.

template<class dType>
gel::GelLinkedList< dType >::GelLinkedList ( const GelLinkedList< dType > &  list) [inline]

Copy constructor.

template<class dType>
gel::GelLinkedList< dType >::~GelLinkedList ( ) [inline]

Destructor.


Member Function Documentation

template<class dType>
void gel::GelLinkedList< dType >::append ( const dType &  newData) [inline]

Inserts an item at the end of the list.

Parameters:
newData: The item to insert.
template<class dType>
void gel::GelLinkedList< dType >::prepend ( const dType &  newData) [inline]

Inserts an item at the beginning of the list.

Parameters:
newData: The item to insert.
template<class dType>
void gel::GelLinkedList< dType >::insert ( int  i,
const dType &  newData 
) [inline]

Inserts an item at the specified index.

Parameters:
i: The index at which to insert the item.
newData: The item to insert.
template<class dType>
void gel::GelLinkedList< dType >::removeFirst ( ) [inline]

Removes the first item in the list.

template<class dType>
void gel::GelLinkedList< dType >::removeLast ( ) [inline]

Removes the last item in the list.

template<class dType>
void gel::GelLinkedList< dType >::remove ( int  i) [inline]

Removes the item at the specified index.

Parameters:
i: The index of the item to remove.
template<class dType>
int gel::GelLinkedList< dType >::removeAll ( dType  val) [inline]

Removes all occurences of the specified value.

Parameters:
val: The value to search for.
Returns:
The number of items removed.
template<class dType>
void gel::GelLinkedList< dType >::replace ( int  i,
const dType &  newData 
) [inline]

Replaces the item at the specified index with a new value.

Parameters:
i: The index of the item to be replaced.
newData: The new value of the item.
template<class dType>
dType& gel::GelLinkedList< dType >::getFirst ( ) [inline]

Gets a reference to the first item in the list.

Returns:
The first item in the list.
template<class dType>
const dType& gel::GelLinkedList< dType >::getFirst ( ) const [inline]

Gets a reference to the first item in the list.

This is an overloaded function.

template<class dType>
dType& gel::GelLinkedList< dType >::getLast ( ) [inline]

Gets a reference to the last item in the list.

Returns:
The last item in the list.
template<class dType>
const dType& gel::GelLinkedList< dType >::getLast ( ) const [inline]

Gets a reference to the last item in the list.

This is an overloaded function.

template<class dType>
dType& gel::GelLinkedList< dType >::getItem ( int  i) [inline]

Gets a reference to the item at the specified index.

Parameters:
i: The index of the item to get.
Returns:
The item at the specified index.
template<class dType>
const dType& gel::GelLinkedList< dType >::getItem ( int  i) const [inline]

Gets a reference to the item at the specified index.

This is an overloaded function.

template<class dType>
dType gel::GelLinkedList< dType >::takeFirst ( ) [inline]

Removes the first item in the list and returns it.

Returns:
The first item in the list.
template<class dType>
dType gel::GelLinkedList< dType >::takeLast ( ) [inline]

Removes the last item in the list and returns it.

Returns:
The last item in the list.
template<class dType>
dType gel::GelLinkedList< dType >::takeItem ( int  i) [inline]

Removes the item at the specified index and returns it.

Parameters:
i: The index of the item to take.
Returns:
The item at the specified index.
template<class dType>
void gel::GelLinkedList< dType >::reverse ( ) [inline]

Reverses the order of the items in the list.

This function currently does not work. Calling it will do nothing.

template<class dType>
int gel::GelLinkedList< dType >::countAll ( dType  val) [inline]

Counts the number of occurences of the specified value.

Parameters:
val: The value to search for.
Returns:
The number of items in the list that are equal to val.
template<class dType>
int gel::GelLinkedList< dType >::getSize ( ) [inline]

Gets the number of items in the list.

Returns:
The number of items in the list.
template<class dType>
void gel::GelLinkedList< dType >::clear ( ) [inline]

Removes all of the items from the list.

template<class dType>
bool gel::GelLinkedList< dType >::isMember ( const dType &  val) [inline]

Checks if the specified value exists in the list.

Parameters:
val: The value to look for.
Returns:
True if the value exists in the list, else false.
template<class dType>
bool gel::GelLinkedList< dType >::isEmpty ( ) [inline]

Determines whether or not the list is empty.

Returns:
True if the list is empty, else false.
template<class dType>
GelLinkedList<dType>& gel::GelLinkedList< dType >::operator= ( const GelLinkedList< dType > &  l) [inline]

Assigns a list to this list.

template<class dType>
GelLinkedList<dType>& gel::GelLinkedList< dType >::operator+= ( const GelLinkedList< dType > &  l) [inline]

Appends all items from a list to this list.

template<class dType>
dType& gel::GelLinkedList< dType >::operator[] ( int  i) [inline]

Gets a reference to the item at the specified index.

See also:
getItem().
template<class dType>
const dType& gel::GelLinkedList< dType >::operator[] ( int  i) const [inline]

Gets a reference to the item at the specified index.

This is an overloaded function.


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