|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jwo.utils.structure.JWPriorityQueue
Class for handling priority queues. A priority queue is an ordered list of objects whose order is determined by a user-supplied priority. The queue can have entries sharing identical priorities, although it should be noted that this version is not optimised for queues with a small number of priorities in comparison to the number of queue entries.
Constructor Summary | |
JWPriorityQueue()
Creates an empty priority queue. |
Method Summary | |
boolean |
containsValue(float priority)
Reports whether or not the priority queue contains an element with the given priority. |
boolean |
containsValue(Object element)
Reports whether or not the priority queue contains the given element. |
Object |
getFirst()
Reports the highest priority element in the queue without removing it. |
Object |
getLast()
Reports the lowest priority element in the queue without removing it. |
float |
getPriority(Object element)
Reports the priority associated with the given object. |
void |
insert(Object element)
Adds an item to the priority queue using the default priority of 0. |
void |
insert(Object element,
float priority)
Adds ('pushes') an item to the priority queue using the given priority. |
static void |
main(String[] args)
Used for testing the priority queue |
boolean |
remove(Object element)
Removes the given element from the queue regardless of its priority. |
Object |
removeFirst()
Reports and removes ('pops') the highest priority element in the queue. |
Object |
removeLast()
Reports and removes ('pops') the lowest priority element in the queue. |
boolean |
setPriority(Object element,
float priority)
Sets the priority associated with the given object. |
int |
size()
Reports the number of elements stored in this priority queue. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public JWPriorityQueue()
Method Detail |
public static void main(String[] args)
public void insert(Object element)
element
- Item to add to the queue.public void insert(Object element, float priority)
element
- Item to add to the queue.priority
- Priority to give added item.public Object getFirst()
public Object getLast()
public Object removeFirst()
public Object removeLast()
public boolean remove(Object element)
element
- Element to remove from queue.
public float getPriority(Object element)
element
- Element from which to find priority.
public boolean setPriority(Object element, float priority)
element
- Element to set with new priority.priority
- New priority to attach to element.
public int size()
public boolean containsValue(Object element)
element
- Element to search for.
public boolean containsValue(float priority)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |