Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Related Pages

Ringbuffers


Detailed Description

Implementation of ring buffers.

It is similar to the vector that stores a series of objects,though the head and the tail are attached inorder to enhance cyclic operations.

Data Structures

Functions


Function Documentation

int rbAddBottomElement RingBuffer  rb,
Pointer  element
 

adds a new element to the bottom of a ring buffer.

Parameters:
rb ringbuffer to which addition has to be done.
element element that has to be added to the ring buffer.
Returns:
the number of elements in the buffer.
Definition at line 138 of file ringbuffer.c.

References rbIsFull().

int rbAddTopElement RingBuffer  rb,
Pointer  element
 

adds a new element to the top of a ring buffer.

Parameters:
rb ringbuffer to which addition has to be done.
element element that has to be added to the ring buffer.
Returns:
the number of elements in the buffer
Definition at line 115 of file ringbuffer.c.

References rbIsFull().

Pointer rbBottomPeek RingBuffer  rb  ) 
 

returns the first inserted element without removing it.

Parameters:
rb ringbuffer from which the bottom element is returned.
Returns:
the first inserted element from the ringbuffer rb.
Definition at line 180 of file ringbuffer.c.

References rbIsEmpty().

int rbCapacity RingBuffer  rb  ) 
 

finds the maximum capacity of the specified buffer.

Parameters:
rb ringbuffer whose maximum capacity is returned.
Returns:
the maximum number of elements the buffer rb can hold.
Definition at line 207 of file ringbuffer.c.

void rbClear RingBuffer  rb  ) 
 

empties the buffer.

Parameters:
rb refers to the buffer that is to be emptied.
Definition at line 338 of file ringbuffer.c.

RingBuffer rbClone RingBuffer  src  ) 
 

makes a new copy of the ring buffer.

Parameters:
src source of the ringbuffer to be cloned.
Returns:
a new copy of a ring buffer after cloning.
Definition at line 306 of file ringbuffer.c.

References rbCopy(), and rbNew().

Boolean rbContains RingBuffer  rb,
Pointer  element
 

checks if the ringbuffer contains a specified element.

Parameters:
rb ringbuffer in which the search has to be made.
element the element to be seached in the ringbuffer rb.
Returns:
TRUE if the buffer contains element, FALSE otherwise.
Definition at line 261 of file ringbuffer.c.

RingBuffer rbCopy RingBuffer  dst,
RingBuffer  src
 

makes a copy of the container from src to dst.

Parameters:
src this refers to the source ring buffer that has to be copied to the destination buffer.
dst this refers to the destination buffer into which the copying has been done.
Returns:
the dst ringbuffer after copying.
Definition at line 283 of file ringbuffer.c.

Referenced by rbClone().

void rbDelete RingBuffer  rb  ) 
 

deletes a ringbuffer.

Parameters:
rb the ringbuffer that is to be deleted.
Definition at line 80 of file ringbuffer.c.

void rbForEachWithData RingBuffer  rb,
VoidFunction *  f,
Pointer  data
 

iterate over all items in the ring buffer and apply a function

Parameters:
rb this is the ring buffer in which the iteration is done.
f this is the function that is used for the iteration in the ring buffer rb.
data determines the data in the ringbuffer.
Definition at line 321 of file ringbuffer.c.

Boolean rbIsEmpty RingBuffer  rb  ) 
 

checks if the given ringbuffer is empty.

Parameters:
rb ringbuffer that is to be checked.
Returns:
TRUE if the buffer is empty and FALSE otherwise.
Definition at line 92 of file ringbuffer.c.

Referenced by rbBottomPeek(), rbRemoveBottomElement(), rbRemoveTopElement(), and rbTopPeek().

Boolean rbIsFull RingBuffer  rb  ) 
 

checks if a given ring buffer is full.

Parameters:
rb ringbuffer that is to be checked
Returns:
TRUE if buffer is full and FALSE otherwise.
Definition at line 103 of file ringbuffer.c.

Referenced by rbAddBottomElement(), and rbAddTopElement().

RingBuffer rbNew int  capacity  ) 
 

creates a new ringbuffer.

Parameters:
capacity specifies the capacity with which the new ringbuffer has to be created.
Returns:
a new ringBuffer with the size capacity.
Definition at line 57 of file ringbuffer.c.

Referenced by rbClone().

Pointer rbRemoveBottomElement RingBuffer  rb  ) 
 

removes the element from the bottom of the buffer.

Parameters:
rb ringbuffer from which the removal is done.
Returns:
the first inserted element in the buffer rb.
Definition at line 240 of file ringbuffer.c.

References rbIsEmpty().

Pointer rbRemoveTopElement RingBuffer  rb  ) 
 

removes the element from the top of the buffer.

Parameters:
rb ringbuffer from which the removal is done.
Returns:
the last inserted element in the buffer rb.
Definition at line 218 of file ringbuffer.c.

References rbIsEmpty().

int rbSize RingBuffer  rb  ) 
 

finds the current size of the buffer.

Parameters:
rb ringbuffer whose size is returned.
Returns:
the current number of elements in the buffer.
Definition at line 196 of file ringbuffer.c.

Pointer rbTopPeek RingBuffer  rb  ) 
 

returns the last inserted element without removing it.

Parameters:
rb ringbuffer from which top element is returned.
Returns:
the last inserted element from the ring buffer rb.
Definition at line 161 of file ringbuffer.c.

References rbIsEmpty().


BLAH 0.95 (20 Oct 2004)