Template for creating circular arrays. More...
#include <circulararray.h>
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. |
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.
CxUtils::CircularArray< T >::CircularArray | ( | const unsigned int | size = 5 ) |
CxUtils::CircularArray< T >::CircularArray | ( | const CircularArray< T > & | another ) |
Copy constructor.
Definition at line 393 of file circulararray.h.
CxUtils::CircularArray< T >::~CircularArray | ( | ) |
Destructor.
Definition at line 407 of file circulararray.h.
iterator CxUtils::CircularArray< T >::begin | ( | ) | [inline] |
Definition at line 309 of file circulararray.h.
const_iterator CxUtils::CircularArray< T >::begin | ( | ) | const [inline] |
Definition at line 316 of file circulararray.h.
void CxUtils::CircularArray< T >::Clear | ( | ) |
Clears contents, but does not delete memory.
Definition at line 419 of file circulararray.h.
void CxUtils::CircularArray< T >::Destroy | ( | ) |
Deletes all allocated memory.
Definition at line 430 of file circulararray.h.
iterator CxUtils::CircularArray< T >::end | ( | ) | [inline] |
Definition at line 331 of file circulararray.h.
const_iterator CxUtils::CircularArray< T >::end | ( | ) | const [inline] |
Definition at line 338 of file circulararray.h.
unsigned int CxUtils::CircularArray< T >::GetFrontIndex | ( | ) | const [inline] |
Definition at line 353 of file circulararray.h.
CircularArray< T > & CxUtils::CircularArray< T >::operator= | ( | const CircularArray< T > & | another ) |
Copies data.
Definition at line 638 of file circulararray.h.
bool CxUtils::CircularArray< T >::PopBack | ( | T * | data = NULL ) |
Remove data from the back of the array.
[out] | data | Copy of the data popped. Set to NULL if you do not wish to get a copy. |
Definition at line 587 of file circulararray.h.
bool CxUtils::CircularArray< T >::PopFront | ( | T * | data = NULL ) |
Remove data from the front of the array.
[out] | data | Copy of the data popped. Set to NULL if you do not wish to get a copy. |
Definition at line 551 of file circulararray.h.
unsigned int CxUtils::CircularArray< T >::PushBack | ( | const T & | data ) |
Add data to the array.
data | Data to be added. |
Definition at line 522 of file circulararray.h.
const_iterator CxUtils::CircularArray< T >::rbegin | ( | ) | const [inline] |
Definition at line 327 of file circulararray.h.
iterator CxUtils::CircularArray< T >::rbegin | ( | ) | [inline] |
Definition at line 323 of file circulararray.h.
const_iterator CxUtils::CircularArray< T >::rend | ( | ) | const [inline] |
Definition at line 349 of file circulararray.h.
iterator CxUtils::CircularArray< T >::rend | ( | ) | [inline] |
Definition at line 345 of file circulararray.h.
unsigned int CxUtils::CircularArray< T >::Reserve | ( | const unsigned int | size ) |
Reserve how large the array is.
size | How large the array is. |
Definition at line 449 of file circulararray.h.
unsigned int CxUtils::CircularArray< T >::Reserved | ( | ) | const |
Definition at line 622 of file circulararray.h.
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.
size | The new size of the array. |
Definition at line 477 of file circulararray.h.
unsigned int CxUtils::CircularArray< T >::Size | ( | ) | const |
Definition at line 630 of file circulararray.h.
unsigned int CxUtils::CircularArray< T >::mElements [protected] |
Number of elements in the array.
Definition at line 365 of file circulararray.h.
T* CxUtils::CircularArray< T >::mpArray [protected] |
The circular array.
Definition at line 368 of file circulararray.h.
unsigned int CxUtils::CircularArray< T >::mPosition [protected] |
Position in the array.
Definition at line 367 of file circulararray.h.
unsigned int CxUtils::CircularArray< T >::mReserved [protected] |
Amount of memory reserved.
Definition at line 366 of file circulararray.h.