EDU.gatech.cc.is.util
Class CircularBuffer

java.lang.Object
  |
  +--EDU.gatech.cc.is.util.CircularBuffer

public class CircularBuffer
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

Implements a circular buffer for storing things.

Copyright (c)2000 Tucker Balch

See Also:
Serialized Form

Field Summary
protected  int buf_size
          size of the buffer.
protected  java.lang.Object[] buffer
          the buffer itself.
protected  int current
          current cell in the buffer.
protected  int total
          total number of items ever added to the buffer.
 
Constructor Summary
CircularBuffer()
          create a CircularBuffer with default values.
CircularBuffer(int s)
          create a CircularBuffer with a specific number of slots.
 
Method Summary
 void clear()
          clears this circular buffer.
 CircularBufferEnumeration elements()
          returns an enumeration of the values in this circular buffer.
 void put(java.lang.Object i)
          adds an item to the CircularBuffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buf_size

protected int buf_size
size of the buffer. Default size is 10.

current

protected int current
current cell in the buffer.

total

protected int total
total number of items ever added to the buffer. This can help reveal if data is ever lost by an enumeration.

buffer

protected java.lang.Object[] buffer
the buffer itself.
Constructor Detail

CircularBuffer

public CircularBuffer()
create a CircularBuffer with default values.

CircularBuffer

public CircularBuffer(int s)
create a CircularBuffer with a specific number of slots.
Parameters:
s - int, number of slots.
Method Detail

put

public void put(java.lang.Object i)
adds an item to the CircularBuffer.
Parameters:
i - Object, the item to add to the buffer.

clear

public void clear()
clears this circular buffer.

elements

public CircularBufferEnumeration elements()
returns an enumeration of the values in this circular buffer.
Returns:
the enumeration.