u6
Class HeapPriorityQueue

java.lang.Object
  |
  +--u6.HeapPriorityQueue

public class HeapPriorityQueue
extends java.lang.Object
implements PriorityQueue

Heap implementation of the PriorityQueue. Stores elements of the key-element pair type in a Heap structure.


Constructor Summary
HeapPriorityQueue(java.util.Comparator cmp)
           
HeapPriorityQueue(Heap emptyHeap)
           
 
Method Summary
 java.lang.Object extract()
          Extracts the element with greater priority, i.e. with minimal key.
 void insert(java.lang.Object key, java.lang.Object element)
          Inserts an element with priority key in this priority queue.
 boolean isEmpty()
          Checks whether this priority queue is empty.
 java.lang.Object minKey()
          Reads the minimal key in this priority queue, without removing the element.
 java.lang.Object minKeyElement()
          Reads the element with minimal key.
 int size()
          Gets the number of entries in this priority queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HeapPriorityQueue

public HeapPriorityQueue(Heap emptyHeap)

HeapPriorityQueue

public HeapPriorityQueue(java.util.Comparator cmp)
Method Detail

insert

public void insert(java.lang.Object key,
                   java.lang.Object element)
Inserts an element with priority key in this priority queue.
Specified by:
insert in interface PriorityQueue
Parameters:
key - the priority value; smaller keys represent greater priority.
element - the element value;

extract

public java.lang.Object extract()
Extracts the element with greater priority, i.e. with minimal key.
Specified by:
extract in interface PriorityQueue
Returns:
the element with minimal key

size

public int size()
Gets the number of entries in this priority queue.
Specified by:
size in interface PriorityQueue
Returns:
the number of elements

isEmpty

public boolean isEmpty()
Checks whether this priority queue is empty.
Specified by:
isEmpty in interface PriorityQueue
Returns:
true iff this priority queue is empty

minKey

public java.lang.Object minKey()
Reads the minimal key in this priority queue, without removing the element.
Specified by:
minKey in interface PriorityQueue

minKeyElement

public java.lang.Object minKeyElement()
Reads the element with minimal key.
Specified by:
minKeyElement in interface PriorityQueue