jgroup.util
Class Queue

java.lang.Object
  extended by jgroup.util.Queue

public final class Queue
extends java.lang.Object

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 object are extracted from the first bucket.

Since:
Jgroup 0.1
Author:
Alberto Montresor, Hein Meling

Constructor Summary
Queue()
          Allocates a queue with default bucket size.
Queue(int bucketSize)
          Allocates a queue with bucket size equal to bucketSize.
 
Method Summary
 void add(Queue addend)
          Add the elements of the addend queue at the end of this queue.
 void clear()
          Removes all the elements from the queue.
 java.lang.Object getFirst()
          Returns the first element of the queue; null if the queue is empty.
 void insert(java.lang.Object object)
          Append object to the end of the queue.
 boolean isEmpty()
          Returns true if the queue is empty.
 java.util.Iterator iterator()
          Returns an iterator over the queue content.
 java.lang.Object removeFirst()
          Removes the first element of the queue.
 int size()
          Returns the size of the queue.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Queue

public Queue(int bucketSize)
Allocates a queue with bucket size equal to bucketSize.

Parameters:
bucketSize - The size of internal buckets.

Queue

public Queue()
Allocates a queue with default bucket size.

Method Detail

insert

public void insert(java.lang.Object object)
Append object to the end of the queue.

Parameters:
object - The object to be inserted.

size

public int size()
Returns the size of the queue.


isEmpty

public boolean isEmpty()
Returns true if the queue is empty.


getFirst

public java.lang.Object getFirst()
Returns the first element of the queue; null if the queue is empty.


removeFirst

public java.lang.Object removeFirst()
Removes the first element of the queue.

Returns:
the first element of the queue; null if the queue is empty.

add

public void add(Queue addend)
Add the elements of the addend queue at the end of this queue.

Parameters:
addend - The queue to be added to the end of this queue.

clear

public void clear()
Removes all the elements from the queue.


iterator

public java.util.Iterator iterator()
Returns an iterator over the queue content.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 1998-2006 The Jgroup/ARM development team. All Rights Reserved.