org.cip4.jdflib.util
Class FastFiFo<x>

java.lang.Object
  extended by org.cip4.jdflib.util.FastFiFo<x>
Type Parameters:
x - the element class to dump into the fifo

public class FastFiFo<x>
extends Object

Author:
Dr. Rainer Prosi, Heidelberger Druckmaschinen AG
quick and dirty fast fifo built on a circular array May 26, 2009

Constructor Summary
FastFiFo(int n)
           
 
Method Summary
 int getFill()
           
 x peek(int i)
          peeks into the fifo from the beginning
 x[] peekArray()
          peeks into the fifo from the beginning
 x pop()
          pops the first to go
 x push(x back)
          pushes an element into the back and returns the previous content of the cell
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FastFiFo

public FastFiFo(int n)
Parameters:
n - size of the fifo
Method Detail

push

public x push(x back)
pushes an element into the back and returns the previous content of the cell

Parameters:
back - the element to push
Returns:
the element that has been replaced, null if we are not yet full

pop

public x pop()
pops the first to go

Returns:
the first element, null if empty

peek

public x peek(int i)
peeks into the fifo from the beginning

Parameters:
i - the index of the element to peek
Returns:
the object at position i

peekArray

public x[] peekArray()
peeks into the fifo from the beginning

Returns:
a snapshot of the current fifo, null if empty

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()

getFill

public int getFill()
Returns:
the current number of elements


Copyright © 2013. All Rights Reserved.