|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectCircularQueue
public class CircularQueue
A simple queue of fixed size, that provides very fast insertion, deletion, and scanning.
Field Summary | |
---|---|
private int |
bottom
Points to the current bottom entry |
private int |
count
Number of entries currently in the queue |
private Object[] |
entries
The current queue entries |
private int |
maxSize
Max # of entries in the queue |
static Tester |
tester
Basic regression test |
Constructor Summary | |
---|---|
CircularQueue(int maxSize)
Construct a queue that can hold, at most, 'maxSize' entries. |
Method Summary | |
---|---|
void |
addHead(Object obj)
Add an object to the start of the queue. |
void |
addTail(Object obj)
Add an object to the end of the queue. |
void |
clear()
Removes all entries from the queue. |
int |
count()
Counts how many items are currently in the queue |
boolean |
isEmpty()
Checks whether the queue is currently empty |
boolean |
isFull()
Checks whether the queue is currently full |
Object |
peek(int distance)
Peek into the queue but do not remove the object. |
Object |
removeHead()
Removes and returns the first object in the queue. |
Object |
removeTail()
Removes and returns the last object in the queue. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private int maxSize
private Object[] entries
private int bottom
private int count
public static final Tester tester
Constructor Detail |
---|
public CircularQueue(int maxSize)
maxSize
- Maximum number of entries in the queueMethod Detail |
---|
public final void addTail(Object obj)
obj
- Object to add.public final void addHead(Object obj)
obj
- Object to add.public final Object removeHead()
public final Object removeTail()
public final Object peek(int distance)
distance
- How far to peek into the queue (zero means peek at the
head, one to peek at head+1, etc.)
public final void clear()
public final int count()
public final boolean isEmpty()
public final boolean isFull()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |