LList< T > Class Template Reference

A doubly-linked list implementation. More...

#include <llist.h>

List of all members.

Public Member Functions

 LList ()
 The default constructor.
 LList (const LList< T > &)
 The copy constructor.
 ~LList ()
 The destructor.
LListoperator= (const LList< T > &)
 The implicit copy operator.
void insert (const T &_newdata)
 Adds data at the end of the list.
void insert_back (const T &_newdata)
 Adds data at the end of the list.
void insert_front (const T &_newdata)
 Adds data at the start of the list.
void insert_at (const T &_newdata, size_t _index)
 Adds data at the specified index.
T const & get (size_t _index) const
 Gets the data at the specified index.
T * getPointer (size_t _index) const
 Gets the address of where the data at the specified index is stored.
void change (T const &_rec, size_t _index)
 Modifies the node at the given index.
void remove (size_t _index)
 Removes the node at the given index.
void removeDataAtEnd ()
 Removes the node at the end of the list.
size_t find (const T &_data)
 Finds a node's index by searching for the given data.
size_t size () const
 Indicates the size of the linked list.
bool valid (size_t _index) const
 Determines whether a given index is within the bounds of the list.
void empty ()
 Deletes all nodes in the list, but does not free memory allocated by data.
T & operator[] (size_t _index)
 Gets the data at the given index.
T const & operator[] (size_t _index) const
 Gets the data at the given index.
void sort (CrissCross::Data::Sorter< T > *_sortMethod)
 Sorts the array using the provided method.
void sort (CrissCross::Data::Sorter< T > &_sortMethod)
 Sorts the array using the provided method.
size_t mem_usage () const
 Returns the overhead caused by the data structure.

Protected Attributes

LListNode< T > * m_first
 The first node.
LListNode< T > * m_last
 The last node.
LListNode< T > * m_previous
 The last accessed node.
size_t m_previousIndex
 The last accessed index.
size_t m_numItems
 The number of nodes in the list.


Detailed Description

template<class T>
class CrissCross::Data::LList< T >

A doubly-linked list implementation.

Member Function Documentation

void change ( T const &  _rec,
size_t  _index 
)

Modifies the node at the given index.

This does not delete the data at the node, just the node itself.

Warning:
Slow unless you're sequentially iterating through.
Parameters:
_rec The new value for the given index.
_index The index of the node to modify.

size_t find ( const T &  _data  ) 

Finds a node's index by searching for the given data.

Parameters:
_data The data to find.
Returns:
-1 if not found, otherwise returns the index.

T const& get ( size_t  _index  )  const [inline]

Gets the data at the specified index.

Warning:
Slow unless you're sequentially iterating through.
Parameters:
_index The index of the data to fetch.
Returns:
The data contained in the node at the index.

T* getPointer ( size_t  _index  )  const [inline]

Gets the address of where the data at the specified index is stored.

Warning:
Slow unless you're sequentially iterating through.
Parameters:
_index The index of the node to find.
Returns:
The pointer to where the data record is stored.

void insert ( const T &  _newdata  )  [inline]

Adds data at the end of the list.

Parameters:
_newdata The data to add to the list.

void insert_at ( const T &  _newdata,
size_t  _index 
)

Adds data at the specified index.

Parameters:
_newdata The data to add to the list.
_index The index where the node should be added.

void insert_back ( const T &  _newdata  ) 

Adds data at the end of the list.

Parameters:
_newdata The data to add to the list.

void insert_front ( const T &  _newdata  ) 

Adds data at the start of the list.

Parameters:
_newdata The data to add to the list.

size_t mem_usage (  )  const

Returns the overhead caused by the data structure.

Returns:
Memory usage in bytes.

T const& operator[] ( size_t  _index  )  const

Gets the data at the given index.

Parameters:
_index The index of the node to get data from.
Returns:
The data stored at the index.

T& operator[] ( size_t  _index  ) 

Gets the data at the given index.

Parameters:
_index The index of the node to get data from.
Returns:
The data stored at the index.

void remove ( size_t  _index  ) 

Removes the node at the given index.

This does not delete the data at the node, just the node itself.

Warning:
Slow unless you're sequentially iterating through.
Parameters:
_index The index of the node to delete.

void removeDataAtEnd (  )  [inline]

Removes the node at the end of the list.

This does not delete the data at the node, just the node itself.

size_t size (  )  const [inline]

Indicates the size of the linked list.

Returns:
The size of the linked list.

void sort ( CrissCross::Data::Sorter< T > &  _sortMethod  ) 

Sorts the array using the provided method.

Parameters:
_sortMethod The method to sort with.

void sort ( CrissCross::Data::Sorter< T > *  _sortMethod  ) 

Sorts the array using the provided method.

Parameters:
_sortMethod The method to sort with.

bool valid ( size_t  _index  )  const [inline]

Determines whether a given index is within the bounds of the list.

Parameters:
_index The index to validate.
Returns:
True if the index is valid, false otherwise.


Member Data Documentation

LListNode<T>* m_previous [mutable, protected]

The last accessed node.

Speeds up searches and sequential access.

size_t m_previousIndex [mutable, protected]

The last accessed index.

Speeds up searches and sequential access.


Generated on Sun Feb 8 11:10:00 2009 for CrissCross by  doxygen 1.5.8