Classes | Public Member Functions | Protected Attributes

CxUtils::CircularArray< T > Class Template Reference

Template for creating circular arrays. More...

#include <circulararray.h>

List of all members.

Classes

class  const_iterator
 Class for iterating through the circular array in a manner that is familiar to those who use the STL. More...
class  const_reverse_iterator
 Class for iterating through the circular array in a manner that is familiar to those who use the STL. More...
class  iterator
 Class for iterating through the circular array in a manner that is familiar to those who use the STL. More...
class  reverse_iterator
 Class for iterating through the circular array in a manner that is familiar to those who use the STL. More...

Public Member Functions

 CircularArray (const unsigned int size=5)
 Constructor.
 CircularArray (const CircularArray< T > &another)
 Copy constructor.
 ~CircularArray ()
 Destructor.
iterator begin ()
const_iterator begin () const
iterator rbegin ()
const_iterator rbegin () const
iterator end ()
const_iterator end () const
iterator rend ()
const_iterator rend () const
unsigned int GetFrontIndex () const
void Clear ()
 Clears contents, but does not delete memory.
void Destroy ()
 Deletes all allocated memory.
unsigned int Reserve (const unsigned int size)
 Reserve how large the array is.
unsigned int Resize (const unsigned int size)
 Resizes the array and preserves any existing data when possible.
unsigned int PushBack (const T &data)
 Add data to the array.
bool PopFront (T *data)
 Remove data from the front of the array.
bool PopBack (T *data)
 Remove data from the back of the array.
unsigned int Reserved () const
unsigned int Size () const
CircularArray< T > & operator= (const CircularArray< T > &another)
 Copies data.

Protected Attributes

unsigned int mElements
 Number of elements in the array.
unsigned int mReserved
 Amount of memory reserved.
unsigned int mPosition
 Position in the array.
T * mpArray
 The circular array.

Detailed Description

template<class T>
class CxUtils::CircularArray< T >

Template for creating circular arrays.

These arrays are of a limited size and do not automatically re-size. When the end of the array is reached than the oldest data is replaced with the latest.

Depending on what direction is set, when indexing either the most recent data (FILO) is at index 0, or the oldest is at index 0 (FIFO). By default data is read out FIFO.

Definition at line 65 of file circulararray.h.


Constructor & Destructor Documentation

template<class T >
CxUtils::CircularArray< T >::CircularArray ( const unsigned int  size = 5 )

Constructor.

Parameters:
sizeDefault size of array.

Definition at line 379 of file circulararray.h.

template<class T>
CxUtils::CircularArray< T >::CircularArray ( const CircularArray< T > &  another )

Copy constructor.

Definition at line 393 of file circulararray.h.

template<class T >
CxUtils::CircularArray< T >::~CircularArray (  )

Destructor.

Definition at line 407 of file circulararray.h.


Member Function Documentation

template<class T>
iterator CxUtils::CircularArray< T >::begin (  ) [inline]

Definition at line 309 of file circulararray.h.

template<class T>
const_iterator CxUtils::CircularArray< T >::begin (  ) const [inline]

Definition at line 316 of file circulararray.h.

template<class T >
void CxUtils::CircularArray< T >::Clear (  )

Clears contents, but does not delete memory.

Definition at line 419 of file circulararray.h.

template<class T >
void CxUtils::CircularArray< T >::Destroy (  )

Deletes all allocated memory.

Definition at line 430 of file circulararray.h.

template<class T>
iterator CxUtils::CircularArray< T >::end (  ) [inline]

Definition at line 331 of file circulararray.h.

template<class T>
const_iterator CxUtils::CircularArray< T >::end (  ) const [inline]

Definition at line 338 of file circulararray.h.

template<class T>
unsigned int CxUtils::CircularArray< T >::GetFrontIndex (  ) const [inline]

Definition at line 353 of file circulararray.h.

template<class T>
CircularArray< T > & CxUtils::CircularArray< T >::operator= ( const CircularArray< T > &  another )

Copies data.

Definition at line 638 of file circulararray.h.

template<class T>
bool CxUtils::CircularArray< T >::PopBack ( T *  data = NULL )

Remove data from the back of the array.

Parameters:
[out]dataCopy of the data popped. Set to NULL if you do not wish to get a copy.
Returns:
Number of elements in array.

Definition at line 587 of file circulararray.h.

template<class T>
bool CxUtils::CircularArray< T >::PopFront ( T *  data = NULL )

Remove data from the front of the array.

Parameters:
[out]dataCopy of the data popped. Set to NULL if you do not wish to get a copy.
Returns:
Number of elements in array.

Definition at line 551 of file circulararray.h.

template<class T>
unsigned int CxUtils::CircularArray< T >::PushBack ( const T &  data )

Add data to the array.

Parameters:
dataData to be added.
Returns:
Number of elements in array.

Definition at line 522 of file circulararray.h.

template<class T>
const_iterator CxUtils::CircularArray< T >::rbegin (  ) const [inline]

Definition at line 327 of file circulararray.h.

template<class T>
iterator CxUtils::CircularArray< T >::rbegin (  ) [inline]

Definition at line 323 of file circulararray.h.

template<class T>
const_iterator CxUtils::CircularArray< T >::rend (  ) const [inline]

Definition at line 349 of file circulararray.h.

template<class T>
iterator CxUtils::CircularArray< T >::rend (  ) [inline]

Definition at line 345 of file circulararray.h.

template<class T >
unsigned int CxUtils::CircularArray< T >::Reserve ( const unsigned int  size )

Reserve how large the array is.

Parameters:
sizeHow large the array is.
Returns:
1 on ok, 0 on fail.

Definition at line 449 of file circulararray.h.

template<class T >
unsigned int CxUtils::CircularArray< T >::Reserved (  ) const
Returns:
The maximum size of the array.

Definition at line 622 of file circulararray.h.

template<class T >
unsigned int CxUtils::CircularArray< T >::Resize ( const unsigned int  size )

Resizes the array and preserves any existing data when possible.

Data is only preserved if you are increasing the size of the array.

Parameters:
sizeThe new size of the array.
Returns:
1 on ok, 0 on fail.

Definition at line 477 of file circulararray.h.

template<class T >
unsigned int CxUtils::CircularArray< T >::Size (  ) const
Returns:
The number of elements in the array.

Definition at line 630 of file circulararray.h.


Member Data Documentation

template<class T>
unsigned int CxUtils::CircularArray< T >::mElements [protected]

Number of elements in the array.

Definition at line 365 of file circulararray.h.

template<class T>
T* CxUtils::CircularArray< T >::mpArray [protected]

The circular array.

Definition at line 368 of file circulararray.h.

template<class T>
unsigned int CxUtils::CircularArray< T >::mPosition [protected]

Position in the array.

Definition at line 367 of file circulararray.h.

template<class T>
unsigned int CxUtils::CircularArray< T >::mReserved [protected]

Amount of memory reserved.

Definition at line 366 of file circulararray.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines