Facemorph
Class PQ

java.lang.Object
  extended by Facemorph.PQ
All Implemented Interfaces:
IPQ

public class PQ
extends java.lang.Object
implements IPQ

Priority Queue class


Constructor Summary
PQ()
          Construct an empty PQ
PQ(int maxsize)
          Construct an empty PQ of initial size maxsize
 
Method Summary
 void add(java.lang.Comparable c)
          Adds an element to the PQ
 void clear()
          Empty the array, alternatively could reallocate
 java.lang.Comparable inspectLeast()
          Inspect but don't remove the smallest element
 boolean isEmpty()
          Check if the heap is empty
static void main(java.lang.String[] args)
          Main method is used for testing
 java.lang.Comparable removeLeast()
          remove the smallest element from the PQ
 int size()
          Return the number of elements in the heap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PQ

public PQ()
Construct an empty PQ


PQ

public PQ(int maxsize)
Construct an empty PQ of initial size maxsize

Parameters:
maxsize - the initial size of the internal storage array
Method Detail

inspectLeast

public java.lang.Comparable inspectLeast()
Inspect but don't remove the smallest element

Specified by:
inspectLeast in interface IPQ
Returns:
returns the smallest element

clear

public void clear()
Empty the array, alternatively could reallocate

Specified by:
clear in interface IPQ

isEmpty

public boolean isEmpty()
Check if the heap is empty

Specified by:
isEmpty in interface IPQ
Returns:
returns true if the heap is empty

size

public int size()
Return the number of elements in the heap

Specified by:
size in interface IPQ
Returns:
Returns the number of elements in the heap

removeLeast

public java.lang.Comparable removeLeast()
remove the smallest element from the PQ

Specified by:
removeLeast in interface IPQ
Returns:
returns the smallest element in the PQ

add

public void add(java.lang.Comparable c)
Adds an element to the PQ

Specified by:
add in interface IPQ
Parameters:
c - the object to add to the PQ

main

public static void main(java.lang.String[] args)
Main method is used for testing

Parameters:
args - the command line args