Methods in the PriorityQueue Interface

 

 

PriorityQueue Interface

void

clear ()

Removes all items from this priority queue.

Object

clone ()

Returns a shallow copy of this priority queue.

Collection

collectionView ()

Returns a collection view of the items contained in this priority queue, without their priorities.

Object

dequeue ()

Returns the item at the head of this priority queue and removes it from the queue.  Throws an exception if the queue is empty.

void

enqueue (Object item)

Adds an item to the tail of the subqueue that has priority 1.  Throws an exception if the item is null.

void

enqueue (Object item, int priority)

Adds an item to the tail of the subqueue that has the specified priority.  Throws an exception is the item is null or the priority is not between 1 and the maximum priority allowed for the queue.

boolean

equals (Object other)

Returns true if the other object is a priority queue that equals this priority queue.  To be equal two priority queues must contain equal items appearing in the same order.  The priorities of these items are ignored.

int

hashCode ()

Returns the hash code value for this priority queue.

boolean

isEmpty ()

Returns true if this priority queue contains no elements.

Iterator

iterator ()

Returns an iterator over the items contained in this priority queue.  The iterator provides the items in their queue order, that is, from  head to tail.  The iterator should not support removal.

Object

peek ()

Returns the item at the head of this priority queue without removing it from the queue.  Throws an exception if the queue is empty.

int

size ()

Returns the number of items in this priority queue.

Object[ ]

toArray ()

Returns an array containing all the items in this priority queue.  The head of the priority queue corresponds to the first item in the array.

String

toString ()

Returns a string that lists the items in this priority queue.  The head of the priority queue corresponding to the first item in the string.  Each item's priority is also shown.

 

martin@cc.wwu.edu
Disclaimer

Copyright Martin Osborne 1998-2001
  All rights reserved