|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.btw.commons.Queue
public final class Queue
Circular buffer (FIFO) of a fixed length. Not thread safe. You must NOT use
the queue as an Enumeration instance: if you want Enumeration please use
getEnumeration().
| Field Summary | |
|---|---|
int |
bufferSize
The size of the buffer. |
| Constructor Summary | |
|---|---|
Queue(int bufferSize)
Creates new buffer. |
|
Queue(Queue other)
Clones given queue. |
|
| Method Summary | |
|---|---|
void |
clear()
Removes all objects from the queue. |
boolean |
equals(Object obj)
|
Enumeration |
getEnumeration()
Returns enumeration of items in this queue. |
int |
hashCode()
|
boolean |
hasMoreElements()
|
boolean |
isEmpty()
Checks if this queue is empty. |
boolean |
isFull()
Checks if this queue is full. |
Object |
nextElement()
|
int |
occupiedSlots()
Returns number of occupied slots in circular buffer array. |
boolean |
offer(Object o)
Inserts the specified element into this queue, if possible. |
boolean |
offerAll(Enumeration other)
Inserts specified elements into this queue, if possible. |
Object |
peek()
Peeks at the head of the queue and returns head item without removing it from the queue. |
Object |
peek(int index)
Peeks at the head of the queue and returns index-th
object beneath the head. |
Object |
poll()
Retrieves and removes the head of this queue, or null if
this queue is empty. |
Object |
removeLast()
Removes last item offered to the queue. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public final int bufferSize
| Constructor Detail |
|---|
public Queue(int bufferSize)
bufferSize - fixed size of the buffer. The buffer can contain no more
items.public Queue(Queue other)
other - clones this queue.| Method Detail |
|---|
public int occupiedSlots()
public Object poll()
null if
this queue is empty.
public boolean offer(Object o)
o - the element to insert.
true if it was possible to add the element to this
queue, else falsepublic boolean offerAll(Enumeration other)
other - the elements to insert.
true if it was possible to add all element to this
queue, false if some or all elements have not been
added.
IllegalArgumentException - if trying to add self.public boolean isFull()
true if the queue is full, false if
it has some room left.public boolean isEmpty()
true if the queue is empty, false
if it contains some elements.public Enumeration getEnumeration()
public boolean hasMoreElements()
hasMoreElements in interface Enumerationpublic Object nextElement()
nextElement in interface Enumerationpublic void clear()
public boolean equals(Object obj)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic String toString()
toString in class Objectpublic Object peek()
null if the queue is empty.public Object peek(int index)
index-th
object beneath the head.
index - the index of the item to retrieve.
null if no such item
exists.public Object removeLast()
offered to the queue. This
allows to use the queue as a LIFO stack aswell.
null if the queue is empty.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||