DataStructures
Class StrictBinaryHeap

java.lang.Object
  |
  +--DataStructures.StrictBinaryHeap
All Implemented Interfaces:
PriorityQueue

public class StrictBinaryHeap
extends java.lang.Object
implements PriorityQueue

Binary heap implementation of a priority queue, in which items of the same priority are removed in order of insertion.

Author:
Peter Williams
See Also:
BinaryHeap

Constructor Summary
StrictBinaryHeap()
          Constructs the binary heap.
 
Method Summary
 void add(java.lang.Comparable item)
          Adds and item to the heap.
 boolean isEmpty()
          Tests if the heap is empty.
 java.lang.Comparable remove()
          Removes an item of highest priority item from the heap.
 int size()
          Returns the current size of the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StrictBinaryHeap

public StrictBinaryHeap()
Constructs the binary heap.
Method Detail

isEmpty

public boolean isEmpty()
Tests if the heap is empty.
Specified by:
isEmpty in interface PriorityQueue
Returns:
true if empty, false otherwise.

size

public int size()
Returns the current size of the queue.
Specified by:
size in interface PriorityQueue
Returns:
the current size of the queue

add

public void add(java.lang.Comparable item)
Adds and item to the heap.
Specified by:
add in interface PriorityQueue
Parameters:
item - the item to add.

remove

public java.lang.Comparable remove()
Removes an item of highest priority item from the heap.

If several items are currently of highest priority, returns them in order of insertion.

Specified by:
remove in interface PriorityQueue
Returns:
the first item of highest priority that was inserted into the heap.
Throws:
NoSuchElementException - if the heap is empty.