jdsl.simple.api
Interface SimplePriorityQueue

All Known Subinterfaces:
PriorityQueue
All Known Implementing Classes:
SequenceSimplePriorityQueue, HeapSimplePriorityQueue

public abstract interface SimplePriorityQueue
extends Container

Interface for a priority queue.

A priority queue defines a total order relation, usually induced by a comparator. A priority queue stores a collection of items (each of which is a key-element pair); it supports the insertion of items whose key in the domain of the total order relation, and the access and removal of items with smallest key.

This interface in the "simple" package defines only the basic methods of a priority queue.

Author:
Michael T. Goodrich, Mark Handy, Roberto Tamassia
See Also:
EmptyContainerException, InvalidKeyException, Comparator, PriorityQueue

Method Summary
 void insertItem(java.lang.Object key, java.lang.Object element)
          Insert an item (key-element pair).
 java.lang.Object minElement()
          Inspect an element (not a key) with smallest key, without modifying the priority queue.
 java.lang.Object minKey()
          Inspect a smallest key (not its element), without modifying the priority queue.
 java.lang.Object removeMinElement()
          Remove an item (key,element) with smallest key.
 
Methods inherited from interface jdsl.simple.api.SimpleContainer
isEmpty, size
 

Method Detail

minElement

public java.lang.Object minElement()
                            throws EmptyContainerException
Inspect an element (not a key) with smallest key, without modifying the priority queue.
Returns:
element with smallest key.
Throws:
EmptyContainerException - if the container is empty.

minKey

public java.lang.Object minKey()
                        throws EmptyContainerException
Inspect a smallest key (not its element), without modifying the priority queue.
Returns:
a smallest key.
Throws:
EmptyContainerException - if the container is empty.

insertItem

public void insertItem(java.lang.Object key,
                       java.lang.Object element)
                throws InvalidKeyException
Insert an item (key-element pair).
Parameters:
key - object.
element - arbitrary object.
Throws:
InvalidKeyException - is thrown if the key is not in the domain of the total order relation.

removeMinElement

public java.lang.Object removeMinElement()
                                  throws EmptyContainerException
Remove an item (key,element) with smallest key.
Returns:
element (not the key) of the removed item.
Throws:
InvalidKeyException - is thrown if the key is not in the domain of the total order relation.