package jutil; /** * A queue sorted by priority. Possible implementations include * sorted list, binary heap, leftist heap, skew heap, etc. */ public interface PriorityQueue extends java.io.Serializable { /** * Removes and returns the highest priority element. * @return highest priority element. * @throws EmptyQueueException if the queue is empty. */ Comparable deleteMin() throws EmptyQueueException; /** * Inserts an element according to its priority. Elements * are assumed to be Comparables compared by priority, where the * smaller element has the higher priority. * @param x the element to be inserted. * @throws OverflowException if the queue is full. */ void insert(Comparable x) throws OverflowException; /** * @return size == 0. */ boolean isEmpty(); /** * @return the number of elements in the queue. */ int size(); /** * Removes all elements from the queue. */ void clear(); }