org.almendra.janet.cas.schedulers
Class PriorityQueue

java.lang.Object
  extended by org.almendra.janet.cas.schedulers.PriorityQueue
All Implemented Interfaces:
IQueue

public class PriorityQueue
extends java.lang.Object
implements IQueue


Field Summary
protected  EDU.oswego.cs.dl.util.concurrent.ReentrantWriterPreferenceReadWriteLock lock
           
protected  java.util.LinkedList[] queues
           
protected  int size
           
 
Constructor Summary
PriorityQueue()
           
PriorityQueue(int numQueues)
           
 
Method Summary
protected  boolean add(IPrioritizedObject prioritizedObject)
           
 boolean add(java.lang.Object object)
          Add an object to the queue.
 java.lang.Object getNext()
          Remove the first object from the queue and return it.
 boolean hasNext()
          Answer whether ther is at least another object in the queue.
protected  void init(int numQueues)
           
 boolean isEmpty()
          Answer true in case the queue is empty otherwise false.
 java.util.Iterator iterator()
          Return an iterator with which to iterate over the queue objects.
 java.lang.Object remove(java.lang.Object object)
          Remove object from aPriorityQueue.
 int size()
          Answer the number of objects in the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queues

protected java.util.LinkedList[] queues

size

protected int size

lock

protected EDU.oswego.cs.dl.util.concurrent.ReentrantWriterPreferenceReadWriteLock lock
Constructor Detail

PriorityQueue

public PriorityQueue()

PriorityQueue

public PriorityQueue(int numQueues)
Method Detail

add

public boolean add(java.lang.Object object)
Description copied from interface: IQueue
Add an object to the queue.

Specified by:
add in interface IQueue
Parameters:
object - the object to be added
Returns:
true if adding the object to the queue was successful otherwise false

add

protected boolean add(IPrioritizedObject prioritizedObject)

getNext

public java.lang.Object getNext()
Description copied from interface: IQueue
Remove the first object from the queue and return it.

Specified by:
getNext in interface IQueue
Returns:

init

protected void init(int numQueues)

isEmpty

public boolean isEmpty()
Description copied from interface: IQueue
Answer true in case the queue is empty otherwise false.

Specified by:
isEmpty in interface IQueue
Returns:

size

public int size()
Description copied from interface: IQueue
Answer the number of objects in the queue.

Specified by:
size in interface IQueue
Returns:

remove

public java.lang.Object remove(java.lang.Object object)
Remove object from aPriorityQueue. This method is inefficient and should be avoided. Use PriorityQueue.getNext() instead.

Specified by:
remove in interface IQueue
Returns:
the removed object or null if not found.

hasNext

public boolean hasNext()
Description copied from interface: IQueue
Answer whether ther is at least another object in the queue.

Specified by:
hasNext in interface IQueue
Returns:

iterator

public java.util.Iterator iterator()
Description copied from interface: IQueue
Return an iterator with which to iterate over the queue objects.

Specified by:
iterator in interface IQueue
Returns: