public interface PriorityQueue {

	/**
	 * Insert into the priority queue, maintaining heap order.
	 * Duplicates and null values are allowed.
	 * Small values of the argument priority means high priority, 
	 * Large values means low priority.
	 * @param obj the item to insert
	 * @param priority the priority to be assigned to the item obj
	 * @exception QueueFullException if the heap is full
	 */
	void insert(Object obj, long priority) throws QueueFullException;

	/**
	 * Deletes and returns the smallest item from the priority queue, maintaining heap order.
	 * @return the the smallest item
	 * @throws QueueEmptyException if the queue is empty 
	 */
	Object deleteMin() throws QueueEmptyException;

	/**
	 * Returns the number of elements in this priority queue.
	 * @return the number of elements in this priority queue.
	 */	
	int size();	
	
	/**
	 * Check whether the heap is empty.
	 * @return true if there are no items in the heap.
	 */
	boolean isEmpty();

	/**
	 * Check whether the heap is full.
	 * @return true if no further elements can be inserted into the heap.
	 */
	boolean isFull();

	/**
	 * Make the heap (logically) empty.
	 */	
	void clear();
}


class QueueFullException extends Exception {
	QueueFullException() {
		super("Priority queue is full" );
	}
}	

class QueueEmptyException extends Exception {
	QueueEmptyException() {
		super("Priority queue is empty" );
	}
}	
