choco.util
Class PriorityQueue

java.lang.Object
  extended by choco.util.PriorityQueue

public class PriorityQueue
extends java.lang.Object

Implements a priority aware queue (FIFO structure).


Constructor Summary
PriorityQueue()
          Constructs a queue with 5 priority levels.
PriorityQueue(int levelNb)
          Constucts a queue with the specified number of priority levels.
 
Method Summary
 boolean add(java.lang.Object o)
          Adds an element to the queue.
 boolean add(java.lang.Object o, int priority)
          Adds an element to the queue with the specified priority.
 boolean addAll(java.util.Collection c)
          Adds all the elments of a collection to the queue.
 void clear()
          Clears all the queue.
 boolean contains(java.lang.Object o)
          Checks if the object is in the queue.
 boolean containsAll(java.util.Collection c)
          Checks if all the element are in the queue.
 boolean equals(java.lang.Object o)
          Checks if the queue is equals to another one.
 boolean isEmpty()
          Checks if the queue is empty.
 java.util.Iterator iterator()
          Iterator without a valid remove method !
 java.lang.Object popFirst()
          Pops the first var in the queue.
 boolean remove(java.lang.Object o)
          Removes the specified object.
 boolean removeAll(java.util.Collection c)
          Removes all the specified objects.
 boolean retainAll(java.util.Collection c)
          Not yet implemented.
 int size()
          Returns the size of the queue.
 java.lang.Object[] toArray()
          Returns an array with all the objects in the queue.
 java.lang.Object[] toArray(java.lang.Object[] a)
          Not yet implemented.
 void updatePriority(java.lang.Object o)
          Updates the location of the element in the list.
 void updatePriority(java.lang.Object o, int priority)
          Updates the location of the element in the list with the specified priority.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PriorityQueue

public PriorityQueue(int levelNb)
Constucts a queue with the specified number of priority levels.


PriorityQueue

public PriorityQueue()
Constructs a queue with 5 priority levels.

Method Detail

add

public boolean add(java.lang.Object o)
Adds an element to the queue. It must be a IPrioritizable object.


add

public boolean add(java.lang.Object o,
                   int priority)
Adds an element to the queue with the specified priority.


addAll

public boolean addAll(java.util.Collection c)
Adds all the elments of a collection to the queue.

Not yet implemented.


clear

public void clear()
Clears all the queue.


contains

public boolean contains(java.lang.Object o)
Checks if the object is in the queue.


containsAll

public boolean containsAll(java.util.Collection c)
Checks if all the element are in the queue.

Not yet implemented.


equals

public boolean equals(java.lang.Object o)
Checks if the queue is equals to another one. Naive implementation: checks the object id.

Overrides:
equals in class java.lang.Object

isEmpty

public boolean isEmpty()
Checks if the queue is empty.

Returns:
true if the queue is empty

iterator

public java.util.Iterator iterator()
Iterator without a valid remove method ! Warning : suppose the set is not modified suring iterating !


popFirst

public java.lang.Object popFirst()
Pops the first var in the queue.


remove

public boolean remove(java.lang.Object o)
Removes the specified object.


removeAll

public boolean removeAll(java.util.Collection c)
Removes all the specified objects.

Not yet implemented.


retainAll

public boolean retainAll(java.util.Collection c)
Not yet implemented.


size

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


toArray

public java.lang.Object[] toArray()
Returns an array with all the objects in the queue.


toArray

public java.lang.Object[] toArray(java.lang.Object[] a)
Not yet implemented.


updatePriority

public void updatePriority(java.lang.Object o)
Updates the location of the element in the list. The object must be IPrioritizable.


updatePriority

public void updatePriority(java.lang.Object o,
                           int priority)
Updates the location of the element in the list with the specified priority.