Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

CB2::List< Tmemb > Class Template Reference

Generic list template. More...

#include <utils.h>

Inheritance diagram for CB2::List< Tmemb >:

CB2::Class List of all members.

Public Types

typedef List< Tmemb > this_type
 Template type alias.

typedef size_t size_type
 Size type.

typedef CB2::List::_item_type item_type
 Item type.

typedef item_typeref_type
 Item reference type.

typedef Iterator< this_type,
ref_type, Tmemb > 
iterator
 Iterator.

typedef RevIterator< this_type,
ref_type, Tmemb > 
rev_iterator
 Reverse iterator.


Public Member Functions

 List ()
 Default constructor.

 List (const this_type &prev)
 Copy constructor.

 ~List ()
 Desctructor.

const this_typeoperator= (const this_type &prev)
 Copy assignment.

const this_typeoperator<< (Tmemb *prev)
 Append item at the end.

const this_typeoperator>> (Tmemb *prev)
 Append item at the beginning.

void PushBack (const Tmemb &prev)
 Append item at the end.

void PushFront (const Tmemb &prev)
 Append item at the beginning.

Tmemb & operator[] (const size_type pos) const
 Get item reference.

void Discart ()
 Discart the array.

size_type Len () const
 Return number of items.

bool Empty () const
 Check array for empty.

Tmemb * Head () const
 Get the first item.

Tmemb * Tail () const
 Get the last item.

ref_type RefBegin () const
 Get starting reference.

ref_type RefEnd () const
 Get final reference.

ref_type RevRefBegin () const
 Get starting reverse reference.

ref_type RevRefEnd () const
 Get final reverse reference.

ref_type RefNext (const ref_type &prev) const
 Get succeding reference.

ref_type RefPrev (const ref_type &prev) const
 Get predecessing reference.

const Tmemb & Deref (const ref_type &ref) const
 Dereference.

const Tmemb & RevDeref (const ref_type &ref) const
 Reverse dereference.

iterator Begin () const
 Get starting iterator.

iterator End () const
 Get final iterator.

rev_iterator RevBegin () const
 Get starting reverse iterator.

rev_iterator RevEnd () const
 Get final reverse iterator.


Public Attributes

int tag
 Tag for user-specific data.


Private Attributes

item_typelist
 Data storage.

item_typetail
 Pointer to the tail of the list.

size_type len
 Members used.


Detailed Description

template<class Tmemb>
class CB2::List< Tmemb >

Generic list template.

This class stores items of the same type in a bi-directional pointer list. The items are stored either as copies or as references (pointers to the original objects).

Unlike Array template, this class is object safe (for objects stored as local copies), but requies a public copy constructor to be present in the Tmemb class.


Member Typedef Documentation

template<class Tmemb>
typedef struct CB2::List::_item_type CB2::List< Tmemb >::item_type
 

Item type.

One item of the list, containing pointer to the data, flag whether the data is allocated by List or a foreign pointer and pointers to previous and next items in the list.

template<class Tmemb>
typedef Iterator< this_type, ref_type, Tmemb> CB2::List< Tmemb >::iterator
 

Iterator.

template<class Tmemb>
typedef item_type* CB2::List< Tmemb >::ref_type
 

Item reference type.

template<class Tmemb>
typedef RevIterator< this_type, ref_type, Tmemb> CB2::List< Tmemb >::rev_iterator
 

Reverse iterator.

template<class Tmemb>
typedef size_t CB2::List< Tmemb >::size_type
 

Size type.

template<class Tmemb>
typedef List< Tmemb> CB2::List< Tmemb >::this_type
 

Template type alias.


Constructor & Destructor Documentation

template<class Tmemb>
CB2::List< Tmemb >::List  )  [inline]
 

Default constructor.

Create empty list.

template<class Tmemb>
CB2::List< Tmemb >::List const this_type prev  )  [inline]
 

Copy constructor.

Copy list items from another list.

Parameters:
prev List to copy from.

template<class Tmemb>
CB2::List< Tmemb >::~List  )  [inline]
 

Desctructor.

Dispose the memory of the list.


Member Function Documentation

template<class Tmemb>
iterator CB2::List< Tmemb >::Begin  )  const [inline]
 

Get starting iterator.

Returns:
Starting iterator.

template<class Tmemb>
const Tmemb& CB2::List< Tmemb >::Deref const ref_type ref  )  const [inline]
 

Dereference.

Get the item value referenced by 'ref'. If the reference is out of range, ExceptionMemory is thrown.

Parameters:
ref Item reference.
Returns:
Item value.

template<class Tmemb>
void CB2::List< Tmemb >::Discart  )  [inline]
 

Discart the array.

Discart the contents of the array.

template<class Tmemb>
bool CB2::List< Tmemb >::Empty  )  const [inline]
 

Check array for empty.

Returns:
True if the array is empty.

template<class Tmemb>
iterator CB2::List< Tmemb >::End  )  const [inline]
 

Get final iterator.

Returns:
Final iterator.

template<class Tmemb>
Tmemb* CB2::List< Tmemb >::Head  )  const [inline]
 

Get the first item.

Returns:
First item in the list.

template<class Tmemb>
size_type CB2::List< Tmemb >::Len  )  const [inline]
 

Return number of items.

Returns:
Number of items in the array.

template<class Tmemb>
const this_type& CB2::List< Tmemb >::operator<< Tmemb *  prev  )  [inline]
 

Append item at the end.

Append one item at the end of the list. Traditionally this operator stores just the pointer to the original instance of the item. If you want to make a local copy, use PushBack() method instead.

Parameters:
prev Item to append.
Returns:
Reference to this.

template<class Tmemb>
const this_type& CB2::List< Tmemb >::operator= const this_type prev  )  [inline]
 

Copy assignment.

Copy list items from another list.

Parameters:
prev List to copy from.

template<class Tmemb>
const this_type& CB2::List< Tmemb >::operator>> Tmemb *  prev  )  [inline]
 

Append item at the beginning.

Append item at the beginning of the list. Traditionally this operator stores just the pointer to the original instance of the item. If you want to make a local copy, use PushFront() method instead.

Parameters:
prev Item to append.
Returns:
Reference to this.

template<class Tmemb>
Tmemb& CB2::List< Tmemb >::operator[] const size_type  pos  )  const [inline]
 

Get item reference.

Get reference to an item from the list indexed by 'pos'. If 'pos' is out of range, ExceptionRange is thrown.

Parameters:
pos Index of the member.
Returns:
Reference to a member.

template<class Tmemb>
void CB2::List< Tmemb >::PushBack const Tmemb &  prev  )  [inline]
 

Append item at the end.

Append one item at the end of the list. This method stores a local copy of the item, so a copy constructor is needed.

Parameters:
prev Item to append.

template<class Tmemb>
void CB2::List< Tmemb >::PushFront const Tmemb &  prev  )  [inline]
 

Append item at the beginning.

Append item at the beginning of the list. This method stores a local copy of the item, so a copy constructor is needed.

Parameters:
prev Item to append.

template<class Tmemb>
ref_type CB2::List< Tmemb >::RefBegin  )  const [inline]
 

Get starting reference.

Get the reference to the first item in the list as a pointer to the first item (or NULL on empty list).

Returns:
Starting reference.

template<class Tmemb>
ref_type CB2::List< Tmemb >::RefEnd  )  const [inline]
 

Get final reference.

Get the final reference as a NULL pointer.

Returns:
Final reference.

template<class Tmemb>
ref_type CB2::List< Tmemb >::RefNext const ref_type prev  )  const [inline]
 

Get succeding reference.

Get the reference to an item succeding the item referenced by 'prev'.

Parameters:
prev Original reference.
Returns:
Next reference.

template<class Tmemb>
ref_type CB2::List< Tmemb >::RefPrev const ref_type prev  )  const [inline]
 

Get predecessing reference.

Get the reference to an item predecessing the item referenced by 'prev'.

Parameters:
prev Original reference.
Returns:
Previous reference.

template<class Tmemb>
rev_iterator CB2::List< Tmemb >::RevBegin  )  const [inline]
 

Get starting reverse iterator.

Returns:
Starting reverse iterator.

template<class Tmemb>
const Tmemb& CB2::List< Tmemb >::RevDeref const ref_type ref  )  const [inline]
 

Reverse dereference.

Get the item value referenced by 'ref'. If the reference is out of range, ExceptionMemory is thrown.

Parameters:
ref Item reference.
Returns:
Item value.

template<class Tmemb>
rev_iterator CB2::List< Tmemb >::RevEnd  )  const [inline]
 

Get final reverse iterator.

Returns:
Final reverse iterator.

template<class Tmemb>
ref_type CB2::List< Tmemb >::RevRefBegin  )  const [inline]
 

Get starting reverse reference.

Get the reverse reference to the last item in the list as a pointer to the last item (or NULL on empty list).

Returns:
Starting reverse reference.

template<class Tmemb>
ref_type CB2::List< Tmemb >::RevRefEnd  )  const [inline]
 

Get final reverse reference.

Get the final reverse reference as a NULL pointer.

Returns:
Final reverse reference.

template<class Tmemb>
Tmemb* CB2::List< Tmemb >::Tail  )  const [inline]
 

Get the last item.

Returns:
Last item in the list.


Member Data Documentation

template<class Tmemb>
size_type CB2::List< Tmemb >::len [private]
 

Members used.

template<class Tmemb>
item_type* CB2::List< Tmemb >::list [private]
 

Data storage.

int CB2::Class::tag [inherited]
 

Tag for user-specific data.

template<class Tmemb>
item_type* CB2::List< Tmemb >::tail [private]
 

Pointer to the tail of the list.


The documentation for this class was generated from the following file:
Generated on Thu Sep 16 23:26:49 2004 for ColorBox2 by doxygen 1.3.7