quick start: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);
description:// 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 } }
static const String CLASS_NAME = L"CircularBuffer";
static const String DEF_PARAM;
static const String PARAM_VALUES;
static const String PARAM_CAPACITY;
static const String PARAM_READ;
static const String PARAM_WRITE;
static const String PARAM_CURR;
static const long DEF_BUF_CAPACITY = 8192;
static const long DEF_READ_IDX = 0;
static const long DEF_WRITE_IDX = -1;
static const long DEF_CURR_IDX = 0;
static const long DEF_OFFSET = 0;
static const long DEF_NUM_READ = 1;
static const long ERR = 41600;
static const long ERR = 41610;
Vector<TObject> v_d
long read_d;
long write_d;
long curr_d;
static Integral::DEBUG debug_level_d;
static MemoryManager mgr_d;
static const String& name();
static boolean diagnose(Integral::DEBUG debug_level);
static boolean setDebug(Integral::DEBUG debug_level);
boolean debug(const unichar* message) const;
~CircularBuffer();
CircularBuffer(long capacity = DEF_BUF_CAPACITY);
CircularBuffer(const CircularBuffer<TObject>& copy_cbuf);
boolean assign(const CircularBuffer<TObject>& copy_cbuf);
CircularBuffer& operator=(const CircularBuffer<TObject>& arg);
long sofSize() const;
boolean read(Sof& sof, long tag);
boolean write(Sof& sof, long tag) const;
boolean read(Sof& sof, long tag, const String& name);
boolean write(Sof& sof, long tag, const String& name) const;
boolean readData(Sof& sof, const String& pname = DEF_PARAM,long size = SofParser::FULL_OBJECT, boolean param_a = true, boolean nested_a = false);
boolean writeData(Sof& sof, const String& name = DEF_PARAM) const;
boolean eq(const CircularBuffer<TObject>& compare_cbuf) const;
static void* operator new(size_t size);
static void* operator new[](size_t size);
static void operator delete(void* ptr);
static void operator delete[](void* ptr);
static boolean setGrowSize(long grow_size);
boolean clear(Integral::CMODE cmode = Integral::DEF_CMODE);
CircularBuffer<TObject>& operator() (long offset);
const CircularBuffer<TObject>& operator() (long offset) const;
boolean getElement(TObject& out, long offset = DEF_OFFSET) const;
boolean getElement(Vector<TObject>& out, long num_elem, long offset = DEF_OFFSET) const;
long getNumElements() const;
long getNumForward() const
long getNumBackward() const;
boolean isFull() const;
boolean isEmpty() const;
long getCapacity() const;
boolean setCapacity(long capacity, boolean preserve_values = true);
boolean append(const TObject& in);
boolean append(const Vector<TObject>& in);
boolean append(const Vector<TObject>& in, long num_elem, long invec_offset = DEF_OFFSET);
boolean prepend(const TObject& in);
boolean prepend(const Vector<TObject>& in);
boolean prepend(const Vector<TObject>& in, long num_elem, long invec_offset = DEF_OFFSET);
boolean resetCurr();
boolean seekCurr(long offset);
boolean setRead(long num_read = DEF_NUM_READ);
#include <Long.h> #include <CircularBuffer.h> int main () { // declare a circular buffer of long // CircularBuffer<Long> cbuf(50); // prepare data // Vector<Long> longs(100); for (long i = 0; i <100; i++) { longs(i) = i; } // add the data to the buffer // cbuf.append(longs, 50, 0); // [0 - 50] were appended // the buffer should be full now // if (!cbuf.isFull()) { // exit // Integral::exit(); } // release some data in buffer and append more data // cbuf.setRead(40); cbuf.append(longs, 10, 50); // [0 - 9] were overwritten // display the contents of the circular buffer // cbuf.debug(L"cbuf"); // exit gracefully // Integral::exit(); }