jjil.algorithm
Interface PriorityQueue

All Known Implementing Classes:
BinaryHeap

public interface PriorityQueue

PriorityQueue interface. Some priority queues may support a decreaseKey operation, but this is considered an advanced operation. If so, a Position is returned by insert. Note that all "matching" is based on the compareTo method.

Author:
Mark Allen Weiss

Nested Class Summary
static interface PriorityQueue.Position
          The Position interface represents a type that can be used for the decreaseKey operation.
 
Method Summary
 ComparableJ2me deleteMin()
          Remove the smallest item from the priority queue.
 ComparableJ2me findMin()
          Find the smallest item in the priority queue.
 PriorityQueue.Position insert(ComparableJ2me x)
          Insert into the priority queue, maintaining heap order.
 boolean isEmpty()
          Test if the priority queue is logically empty.
 void makeEmpty()
          Make the priority queue logically empty.
 int size()
          Returns the size.
 

Method Detail

insert

PriorityQueue.Position insert(ComparableJ2me x)
                              throws Error
Insert into the priority queue, maintaining heap order. Duplicates are allowed.

Parameters:
x - the item to insert.
Returns:
may return a Position useful for decreaseKey.
Throws:
Error - if x is not of the correct type or null.

findMin

ComparableJ2me findMin()
                       throws Error
Find the smallest item in the priority queue.

Returns:
the smallest item.
Throws:
Error - if the heap is empty.

deleteMin

ComparableJ2me deleteMin()
                         throws Error
Remove the smallest item from the priority queue.

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

isEmpty

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

Returns:
true if empty, false otherwise.

makeEmpty

void makeEmpty()
Make the priority queue logically empty.


size

int size()
Returns the size.

Returns:
current size.