edu.jhu.ece.iacl.jist.structures.data
Class BinaryMinFastHeap

java.lang.Object
  extended by edu.jhu.ece.iacl.jist.structures.data.BinaryMinFastHeap

public class BinaryMinFastHeap
extends java.lang.Object

Implements a binary heap. Note that all "matching" is based on the compareTo method.

Author:
Mark Allen Weiss

Constructor Summary
BinaryMinFastHeap(Indexable[] items)
          Construct the binary heap from an array.
BinaryMinFastHeap(int capacity, int XN, int YN, int ZN)
          Instantiates a new binary min fast heap.
 
Method Summary
 void add(Indexable x)
          Insert into the priority queue.
 void change(int i, int j, int k, Indexable x)
          Change.
 long hash(int i, int j, int k, int c)
          Hash.
 boolean isEmpty()
          Test if the priority queue is logically empty.
 int lookup(int i, int j, int k, int c)
          Lookup.
 void makeEmpty()
          Make the priority queue logically empty.
 Indexable peek()
          Find the smallest item in the priority queue.
 void percolateUp(int k)
          Percolate up.
 Indexable remove()
          Remove the smallest item from the priority queue.
 int size()
          Returns size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryMinFastHeap

public BinaryMinFastHeap(int capacity,
                         int XN,
                         int YN,
                         int ZN)
Instantiates a new binary min fast heap.

Parameters:
capacity - the capacity
XN - the xN
YN - the yN
ZN - the zN

BinaryMinFastHeap

public BinaryMinFastHeap(Indexable[] items)
Construct the binary heap from an array.

Parameters:
items - the inital items in the binary heap.
Method Detail

hash

public long hash(int i,
                 int j,
                 int k,
                 int c)
Hash.

Parameters:
i - the i
j - the j
k - the k
c - the c
Returns:
the long

lookup

public int lookup(int i,
                  int j,
                  int k,
                  int c)
Lookup.

Parameters:
i - the i
j - the j
k - the k
c - the c
Returns:
the int

add

public void add(Indexable x)
Insert into the priority queue. Duplicates are allowed.

Parameters:
x - the item to insert.

percolateUp

public void percolateUp(int k)
Percolate up.

Parameters:
k - the k

change

public void change(int i,
                   int j,
                   int k,
                   Indexable x)
Change.

Parameters:
i - the i
j - the j
k - the k
x - the x

peek

public Indexable peek()
Find the smallest item in the priority queue.

Returns:
the smallest item.
Throws:
UnderflowException - if empty.

remove

public Indexable remove()
Remove the smallest item from the priority queue.

Returns:
the smallest item.
Throws:
UnderflowException - if empty.

isEmpty

public boolean isEmpty()
Test if the priority queue is logically empty.

Returns:
true if empty, false otherwise.

size

public int size()
Returns size.

Returns:
current size.

makeEmpty

public void makeEmpty()
Make the priority queue logically empty.