Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

cbuffer< T, A > Class Template Reference
[GLT Misc]

Templated Circular Buffer Container. More...

#include <cbuffer.h>

Inheritance diagram for cbuffer< T, A >:

Inheritance graph
[legend]
List of all members.

Public Methods

 cbuffer (const size_type capacity=0, const T &def=T())
 Construct a circular buffer, specifying the capacity.

 ~cbuffer ()
 Destructor.

size_type capacity () const
 Get the buffer capacity (maximim size).

size_type size () const
 Get the buffer size.

bool empty () const
 Is the buffer empty?

bool full () const
 Is the buffer full?

void push_front (const T &x)
 Push an item to the front of the buffer.

void push_back (const T &x)
 Push an item to the back of the buffer.

void pop_front ()
 Erase the item at the front of the buffer.

void pop_back ()
 Erase the item at the back of the buffer.

T & front ()
 Access the front item.

const T & front () const
 Access the front item.

T & back ()
 Access the back item.

const T & back () const
 Access the back item.

T & operator[] (const size_type i)
 Access the i'th item in the buffer.

const T & operator[] (const size_type i) const
 Access the i'th item in the buffer.

void leftShift ()
 Shift the contents left.

void rightShift ()
 Shift the contents right.

void clear ()
 Clear the buffer.

void swap (cbuffer< T, A > &buffer)
 Swap the contents of this buffer with another.

void resize (const size_type cap)
 Resize the (capacity) of the buffer.


Detailed Description

template<class T, class A = std::allocator<T>>
class cbuffer< T, A >

Templated Circular Buffer Container.

Todo:
Regression test programs

iterator and const_iterator implementation

Should objects be deleted as needed, or on demand?

Semantics for circular buffer of zero size?

Definition at line 46 of file cbuffer.h.


Constructor & Destructor Documentation

template<class T, class A = std::allocator<T>>
cbuffer< T, A >::cbuffer const size_type    capacity = 0,
const T &    def = T()
[inline]
 

Construct a circular buffer, specifying the capacity.

Parameters:
capacity  Capacity of buffer
def  Default

Definition at line 61 of file cbuffer.h.


Member Function Documentation

template<class T, class A = std::allocator<T>>
void cbuffer< T, A >::push_front const T &    x [inline]
 

Push an item to the front of the buffer.

Parameters:
x  Item to push to the front
Because the buffer is circular, the last item will be overwritten if the buffer is already full.

Definition at line 107 of file cbuffer.h.

template<class T, class A = std::allocator<T>>
void cbuffer< T, A >::push_back const T &    x [inline]
 

Push an item to the back of the buffer.

Parameters:
x  Item to push to the back
Because the buffer is circular, the first item will be overwritten if the buffer is already full.

Definition at line 131 of file cbuffer.h.

template<class T, class A = std::allocator<T>>
void cbuffer< T, A >::resize const size_type    cap [inline]
 

Resize the (capacity) of the buffer.

Parameters:
capacity  new capacity
If the new buffer capacity is too small for the existing contents, only the front-most items will remain.

Definition at line 279 of file cbuffer.h.


The documentation for this class was generated from the following file:
Generated on Tue Nov 5 11:11:41 2002 for GLT by doxygen1.2.18