|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--anthill.util.Queue
The Queue
class implements a queue with last-in, first-out
semantics. The queue is implemented as a linked list of buckets, each of
them contains a fixed number of objects. Appended objects are inserted in
the last bucket (if full, a new bucket is allocated), while removed buckets
are extracted from the first bucket.
Constructor Summary | |
Queue()
Allocates a queue with default bucket size |
|
Queue(int size)
Allocates a queue with bucket size equal to size <\code>. |
Method Summary | |
void |
add(Object object)
Appends object <\code> at the end of the queue. |
void |
clear()
Removes all the elements from the queue. |
Object |
get()
Returns the first element of the queue. |
boolean |
isEmpty()
Returns true if the queue is empty. |
static void |
main(String[] args)
|
void |
merge(Queue addend)
Add the elements of the addend queue at the end of this queue. |
Object |
remove()
Removes the first element of the queue. |
int |
size()
Returns the number of elements contained in this queue |
Object[] |
toArray()
Copies the element of the queue in an array of objects, in the queue order. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Queue(int size)
size <\code>.
- Parameters:
size
- the size of internal buckets.
public Queue()
Method Detail |
public void add(Object object)
object <\code> at the end of the queue.
- Parameters:
object
- the object to be inserted
public boolean isEmpty()
public int size()
public Object get()
public Object remove()
public void merge(Queue addend)
addend
- the queue to be addedpublic void clear()
public Object[] toArray()
public static void main(String[] args)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |