CircularBuffer<type> class public functions

CircularBuffer
~CircularBuffer
CircularBuffer<type>
capacity
extract
getCount
getSize
insert
operator[]
read
reset
setSize
write

CircularBuffer<type>(void);
Sets the allocation size to 0. The setSize function must be called before using.

CircularBuffer<type>(int maxElements);
Sets the allocation size of the buffer to maxElements and sets the read and write index to the same position in an uninitialized buffer.

CircularBuffer<type>(const CircularBuffer<type>& anotherBuffer);
Copyies the state of anotherBuffer as well as its contents.

~CircularBuffer();
Deletes the allocated space for the buffer.

int capacity(void) const;
Returns the number of items which can be added to the buffer. Returns a positive number if the buffer has empty locations available. Returns 0 if the buffer is 100% full. Returns a negative number if the buffer has overflowed.

type extract(void);
Reads the next value from the buffer and advances the read index.

int getCount(void) const;
Returns the number of elements between the write index and the read index.

int getSize(void) const;
Returns the allocated size of the buffer which is equal to the maximum number of values which can be stored in the buffer.

void insert(const type& aMessage);
Add an element to the circular buffer which will advance the write index by 1.

type& operator[](int index);
Accesor to an element relative to the currently written element.

type read(void);
An alias for the extract function.

void reset(void);
Throws out all previous data and sets the read/write/count values to an initial state. The allocation size must be valid before this function is called.

void setSize(int aSize);
Changes the allocation size of the buffer. All previous values in the buffer will be lost.

void write(const type& aMessage);
An alias for the insert function.