org.exolab.core.util
Class OrderedQueue

java.lang.Object
  extended by org.exolab.core.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.2 $ $Date: 2003/01/19 02:45:59 $
Author:
Jim Alateras

Constructor Summary
OrderedQueue(java.util.Comparator comparator)
          Instantiate an instance of this class with the specified comparator the comparator is used 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)
Instantiate an instance of this class with the specified comparator the comparator is used 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

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-2012 The Exolab Group. All Rights Reserved.