name: CircularBuffer<class TObject>

synopsis:

g++ [flags ...] file ...

#include <CircularBuffer.h>
CircularBuffer(long capacity = DEF_BUF_CAPACITY);
boolean append(const TObject in);  
boolean append(const Vector>TObject<& in);
boolean seekCurr(long offset);
boolean setRead(long num_read = DEF_NUM_READ);
quick start:

// declare a Float CircularBuffer of capacity 5
//
CircularBuffer<Float> cbuf(5);

for (long i = 0; i < 5; i++) {
  Float num((float)i);
  cbuf.append(num);
}

// check the number of elements and if the buffer is full
//
if (cbuf.getNumElements() != 5 || !cbuf.isFull()) {
     // error
  }
}
description:

The CircularBuffer class is a circular Vector of TObjects. A CircularBuffer has a read, a write and a current index indicating positions in the Vector. The elements between the read and write indices are the valid elements. When new data is added to the CircularBuffer, it is appended to the position next to the write index, then the write index is advanced. The read index is used to indicate that you have read those data, so they are allowed to be overwritten by the new data. If the CircularBuffer is full, new data are not allowed to be added until some of the current data have been read.

dependencies:

public constants:

error codes:

protected data:

required public methods:

class-specific public methods:

private methods:

friend classes:

examples:

notes: