Package com.sun.javatest.util
Class Fifo
- java.lang.Object
-
- com.sun.javatest.util.Fifo
-
public class Fifo extends java.lang.ObjectA simple variable length first-in first-out queue.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidflush()Flush all entries from the buffer.voidinsert(java.lang.Object obj)Insert an entry into the buffer.booleanisEmpty()Check if the buffer has an entries or not.java.lang.Objectremove()Remove an entry from the buffer if one is available.intsize()Return the number of entries currently in the fifo.
-
-
-
Constructor Detail
-
Fifo
public Fifo()
Create a buffer with a default initial size.
-
Fifo
public Fifo(int initialSlots)
Create a buffer with a specified initial size.- Parameters:
initialSlots- The number of initial slots in the buffer; the number of slots required by the buffer will be expanded as required.
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
Check if the buffer has an entries or not.- Returns:
- true if the buffer has no entries, and false otherwise.
-
size
public int size()
Return the number of entries currently in the fifo.- Returns:
- The number of entries currently in the fifo
-
insert
public void insert(java.lang.Object obj)
Insert an entry into the buffer. The buffer will be increased in size if necessary to accommodate the new entry.- Parameters:
obj- The object to be inserted. It must not be null.
-
remove
public java.lang.Object remove()
Remove an entry from the buffer if one is available.- Returns:
- The next object in line to be removed, if one is available, or null if none are available.
-
flush
public void flush()
Flush all entries from the buffer.
-
-