|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfi.joensuu.cs.tra.AssignablePriorityQueue<E>
public class AssignablePriorityQueue<E>
AssignablePriorityQueue is a wrapper for java.util.PriorityQueue that allows specifying an float priority for each element. For example
AssignablePriorityQueuewould produceapq = new AssignablePriorityQueue (); apq.add("four", 4); apq.add("eighteen", 18); apq.add("gazillion", -1); apq.add("two", 2); String polled; while ((polled = apq.poll()) != null) { System.out.print(polled); System.out.print(" "); } System.out.println();
gazillion two four eighteen
PriorityQueue
Constructor Summary | |
---|---|
AssignablePriorityQueue()
Creates an AssignablePriorityQueue with the default initial capacity (11) that orders its elements according to the natural ordering of their assigned priorities. |
|
AssignablePriorityQueue(int initialCapacity)
Creates an AssignablePriorityQueue with the specified initial capacity (11) that orders its elements according to the natural ordering of their assigned priorities. |
Method Summary | |
---|---|
boolean |
add(E element,
float priority)
Inserts a specified element to the priority queue with the specified priority. |
boolean |
add(float priority,
E element)
Deprecated. Use add(E element, float priority) instead. |
void |
clear()
Remove all elements from the priority queue. |
Iterator<E> |
iterator()
Returns an iterator over the elements in this queue. |
E |
peek()
Retrieves, but does not remove, the head of this queue, returning null if this queue is empty. |
E |
poll()
Removes and returns the head of this queue, or null if this queue is empty. |
int |
size()
Returns the number of elements in this queue. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AssignablePriorityQueue()
public AssignablePriorityQueue(int initialCapacity)
Method Detail |
---|
public boolean add(float priority, E element)
priority
- the priority to be assigned to the elementelement
- the element to be inserted
NullPointerException
- if the specified element is nullpublic boolean add(E element, float priority)
priority
- the priority to be assigned to the elementelement
- the element to be inserted
NullPointerException
- if the specified element is nullpublic Iterator<E> iterator()
public int size()
public void clear()
public E poll()
public E peek()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |