ann.util.Queue

 

Queue.java presents a Queue of linked nodes built "from scratch" whose integrity cannot be violated (unlike Java's Queue class). Uses ann.util.SinglyLinkedNode to store its values.

 

 

public Queue()

Default constructor

Postcondition: Empty stack is constructed.

 

public boolean isEmpty()

Check if queue is empty

Return: true if queue is empty, and false otherwise

 

public Object first()

First operation

Return: Object at the front of the queue; null if queue is empty

 

public void add(Object obj)

Add operation

Receive: Object value

Postcondition: value has been added at the back of the queue

 

public Object remove()

Remove operation

Return: Object at the front of the queue; null if queue is empty

Postcondition: Value at the front of the queue has been removed.

 

public int getSize()

Size accessor

Return: number of elements in the queue

 

public void clear()

Clear mutator

Postcondition: All values have been removed from the queue.

 

public String toString()

String conversion for output purposes

 


Back to the package documentation index


Back to the Introduction


Copyright 2000 by Prentice Hall. All rights reserved.