Methods in the Queue Interface

 

 

Queue Interface

void

clear ()

Removes all items from this queue.

Object

clone ()

Returns a shallow copy of this queue.

Collection

collectionView ()

Returns a collection view of the items contained in this queue.

Object

dequeue ()

Returns the item at the head of this 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 this queue.  Throws an exception if the item is null.

boolean

equals (Object other)

Returns true if the other object is a queue that equals this queue.  To be equal two queues must contain equal items appearing in the same order.

int

hashCode ()

Returns the hash code value for this queue.

boolean

isEmpty ()

Returns true if this queue contains no elements.

Iterator

iterator ()

Returns an iterator over the items contained in this 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 queue without removing it from the queue.  Throws an exception if the queue is empty.

int

size ()

Returns the number of items in this queue.

Object[ ]

toArray ()

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

String

toString ()

Returns a string that lists the items in this queue.  The head of the queue corresponds to the first item in the string.

 

martin@cc.wwu.edu
Disclaimer

Copyright Martin Osborne 1998-2001
  All rights reserved