Package org.deepjava.runtime.util
Class ByteFifo
- java.lang.Object
-
- org.deepjava.runtime.util.ByteFifo
-
public class ByteFifo extends Object
First in first outbyte
queue. The size of the queue should be a multiple of 2 minus one (size = 2^x - 1).
-
-
Constructor Summary
Constructors Constructor Description ByteFifo(int size)
Creates a newByteFifo
withsize
entries.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
availToRead()
Reads the available entries in the queue.int
availToWrite()
Reads the available space left in the queue.void
clear()
Clears the queue.byte
dequeue()
Removes onebyte
from the queue.void
enqueue(byte data)
Inserts onebyte
into the queue.int
getSize()
Reads the maximum number of entries in the queue.
-
-
-
Method Detail
-
enqueue
public void enqueue(byte data)
Inserts onebyte
into the queue.- Parameters:
data
-Byte
which will be inserted into the queue
-
dequeue
public byte dequeue() throws IOException
Removes onebyte
from the queue.- Returns:
- The removed byte.
- Throws:
IOException
- if reading from an empty queue.
-
clear
public void clear()
Clears the queue.
-
availToRead
public int availToRead()
Reads the available entries in the queue.- Returns:
- The available
bytes
to 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.
-
-