structure
Class VectorHeap

java.lang.Object
  extended by structure.VectorHeap
All Implemented Interfaces:
PriorityQueue

public class VectorHeap
extends Object
implements PriorityQueue

This class implements a priority queue based on a traditional array-based heap.


Constructor Summary
VectorHeap()
          Construct a new priority queue
VectorHeap(Vector v)
          Construct a new priority queue from an unordered vector
 
Method Summary
 void add(Comparable value)
          Add a value to the priority queue.
 void clear()
          Remove all the elements from the queue.
 Comparable getFirst()
          Fetch lowest valued (highest priority) item from queue.
 boolean isEmpty()
          Determine if the queue is empty.
 Comparable remove()
          Returns the minimum value from the queue.
 int size()
          Determine the size of the queue.
 String toString()
          Construct a string representation of the heap.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VectorHeap

public VectorHeap()
Construct a new priority queue


VectorHeap

public VectorHeap(Vector v)
Construct a new priority queue from an unordered vector

Method Detail

getFirst

public Comparable getFirst()
Fetch lowest valued (highest priority) item from queue.

Specified by:
getFirst in interface PriorityQueue
Returns:
The smallest value from queue.

remove

public Comparable remove()
Returns the minimum value from the queue.

Specified by:
remove in interface PriorityQueue
Returns:
The minimum value in the queue.

add

public void add(Comparable value)
Add a value to the priority queue.

Specified by:
add in interface PriorityQueue
Parameters:
value - The value to be added.

isEmpty

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

Specified by:
isEmpty in interface PriorityQueue
Returns:
True if the queue is empty.

size

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

Specified by:
size in interface PriorityQueue
Returns:
The number of elements within the queue.

clear

public void clear()
Remove all the elements from the queue.

Specified by:
clear in interface PriorityQueue

toString

public String toString()
Construct a string representation of the heap.

Overrides:
toString in class Object
Returns:
The string representing the heap.