org.jcpsim.util
Class RingBuffer<Item>

java.lang.Object
  extended by org.jcpsim.util.RingBuffer<Item>

public class RingBuffer<Item>
extends java.lang.Object


Constructor Summary
RingBuffer(int length)
           
 
Method Summary
 Item get()
          Gets the actual element.
 Item get(int i)
          Retrieves a value from the buffer.
 int getLength()
           
 boolean isEmpty()
           
 void put(Item item)
          Writes an item value to the buffer.
 void reset(int length)
           
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RingBuffer

public RingBuffer(int length)
Method Detail

reset

public void reset(int length)

isEmpty

public boolean isEmpty()

size

public int size()

getLength

public int getLength()

put

public void put(Item item)
Writes an item value to the buffer.

Parameters:
item - the value

get

public Item get()
Gets the actual element. Does not check if the buffer is empty (for sake of speed).

Returns:
the newest (= actual) element

get

public Item get(int i)
Retrieves a value from the buffer. To read all values:
for (int i=0; i.

Parameters:
i - 0: the newest value in the buffer; 1: the newest but one value; size()-1: the oldest value
Returns:
the value


jCpSim (Java CardioPulmonary SIMulations), v0.2.01
Dr. Frank Fischer, frank@jcpsim.org, http://www.jcpsim.org