Package org.deepjava.runtime.util
Class IntFifo
- java.lang.Object
-
- org.deepjava.runtime.util.IntFifo
-
public class IntFifo extends Object
First in first outIntegerqueue. The size of the queue should be a multiple of 2 minus one (size = 2^x - 1).
-
-
Constructor Summary
Constructors Constructor Description IntFifo(int size)Creates a newIntFifowithsizeentries.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailToRead()Reads the available entries in the queue.intavailToWrite()Reads the available space left in the queue.voidclear()Clears the queue.intdequeue()Removes oneIntegerfrom the queue.voidenqueue(int data)Inserts oneIntegerinto the queue.intgetSize()Reads the maximum number of entries in the queue.
-
-
-
Field Detail
-
NO_DATA
public static final int NO_DATA
- See Also:
- Constant Field Values
-
data
int[] data
-
head
int head
-
tail
int tail
-
size
int size
-
-
Method Detail
-
enqueue
public void enqueue(int data)
Inserts oneIntegerinto the queue.- Parameters:
data-Integerwhich will be inserted into the queue
-
dequeue
public int dequeue()
Removes oneIntegerfrom the queue.- Returns:
- The removed Integer or @see
NO_DATAif no data is present
-
clear
public void clear()
Clears the queue.
-
availToRead
public int availToRead()
Reads the available entries in the queue.- Returns:
- The available
Integersto read.
-
availToWrite
public int availToWrite()
Reads the available space left in the queue.- Returns:
- The available queue space.
-
getSize
public int getSize()
Reads the maximum number of entries in the queue.- Returns:
- The size of the queue.
-
-