Class MyPriorityQueue

java.lang.Object
  |
  +--MyQueue
        |
        +--MyPriorityQueue
All Implemented Interfaces:
Queue

public class MyPriorityQueue
extends MyQueue

A queue that places new entries in order within the queue, rather than at the end.

Version:
03 Mar, 2005
Author:
Zach Tomaszewski

Fields inherited from class MyQueue
tail
 
Constructor Summary
MyPriorityQueue()
           
 
Method Summary
 void enqueue(Object obj)
          Adds a given element to this priority queue.
 
Methods inherited from class MyQueue
dequeue, empty, front, toString
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MyPriorityQueue

public MyPriorityQueue()
Method Detail

enqueue

public void enqueue(Object obj)
             throws ClassCastException
Adds a given element to this priority queue. Places the new element in sorted order within this queue. If there are multiple equivalent elements, new elements are added after all equivalent items already in the queue. The given object must be Comparable.

Unlike queue, this is no longer an O(1) operation.

Overrides:
enqueue in class MyQueue
Parameters:
obj - A Comparable object to add to this queue
Throws:
ClassCastException - If obj is not Comparable
See Also:
Comparable