org.exolab.jms.common.util
Class OrderedQueue

java.lang.Object
  |
  +--org.exolab.jms.common.util.OrderedQueue

public class OrderedQueue
extends java.lang.Object

The OrderedQueue is responsible for managing the expiration of the leases. The LeaseComparator is used to determine where they are inserted and the lease with the shortest duration is removed from the queue first. It is implemented suing a Vector but this could be changed to improve performance.

Version:
$Revision: 1.1 $ $Date: 2004/11/26 01:50:35 $
Author:
Jim Alateras

Constructor Summary
OrderedQueue(java.util.Comparator comparator)
          Construct an instance of this class with the comparator to order the elements in the queue.
 
Method Summary
 void add(java.lang.Object object)
          Add this element to the queue in the required order.
 void clear()
          Remove all the elements from the queue
 java.lang.Object firstElement()
          Return the first element on the queue
 boolean remove(java.lang.Object object)
          Remove the object from the queue
 java.lang.Object removeFirstElement()
          Remove the first element from the queue or null if there are no elements on the queue.
 int size()
          Return the number elements in the queue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrderedQueue

public OrderedQueue(java.util.Comparator comparator)
Construct an instance of this class with the comparator to order the elements in the queue. Elements with the same order value are placed after each other.
Parameters:
comparator - used for ordering
Method Detail

add

public void add(java.lang.Object object)
Add this element to the queue in the required order. It uses a binary search to locate the correct position
Parameters:
object - object to add

remove

public boolean remove(java.lang.Object object)
Remove the object from the queue
Parameters:
object - object to remove
Returns:
true if the object was removed

clear

public void clear()
Remove all the elements from the queue

size

public int size()
Return the number elements in the queue
Returns:
int size of the queue

firstElement

public java.lang.Object firstElement()
Return the first element on the queue
Returns:
Object

removeFirstElement

public java.lang.Object removeFirstElement()
Remove the first element from the queue or null if there are no elements on the queue.
Returns:
Object


Copyright © 1999-2007 The OpenJMS Group. All Rights Reserved.