jutil
Interface PriorityQueue

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
BinaryHeap

public interface PriorityQueue
extends java.io.Serializable

A queue sorted by priority. Possible implementations include sorted list, binary heap, leftist heap, skew heap, etc.


Method Summary
 void clear()
          Removes all elements from the queue.
 java.lang.Comparable deleteMin()
          Removes and returns the highest priority element.
 void insert(java.lang.Comparable x)
          Inserts an element according to its priority.
 boolean isEmpty()
           
 int size()
           
 

Method Detail

deleteMin

java.lang.Comparable deleteMin()
                               throws EmptyQueueException
Removes and returns the highest priority element.

Returns:
highest priority element.
Throws:
EmptyQueueException - if the queue is empty.

insert

void insert(java.lang.Comparable x)
            throws OverflowException
Inserts an element according to its priority. Elements are assumed to be Comparables compared by priority, where the smaller element has the higher priority.

Parameters:
x - the element to be inserted.
Throws:
OverflowException - if the queue is full.

isEmpty

boolean isEmpty()
Returns:
size == 0.

size

int size()
Returns:
the number of elements in the queue.

clear

void clear()
Removes all elements from the queue.