structure
Interface Queue

All Superinterfaces:
Linear, Structure
All Known Implementing Classes:
AbstractQueue, QueueArray, QueueList, QueueVector

public interface Queue
extends Linear

A first-in, first-out structure. Values are added at the tail, and removed from the head. Used to process values in the order that they appear.

See Also:
Stack

Method Summary
 void add(java.lang.Object value)
          Add a value to the tail of the queue.
 java.lang.Object dequeue()
          Remove a value from the head of the queue.
 boolean empty()
          Returns true iff the queue is empty.
 void enqueue(java.lang.Object value)
          Add a value to the tail of the queue.
 java.lang.Object get()
          Fetch the value at the head of the queue.
 java.lang.Object getFirst()
          Fetch the value at the head of the queue.
 java.lang.Object peek()
          Fetch the value at the head of the queue.
 java.lang.Object remove()
          Remove a value form the head of the queue.
 int size()
          Returns the number of elements in the queue.
 
Methods inherited from interface structure.Structure
clear, contains, elements, isEmpty, iterator, remove, values
 

Method Detail

add

void add(java.lang.Object value)
Add a value to the tail of the queue.

Specified by:
add in interface Linear
Specified by:
add in interface Structure
Parameters:
value - The value added.
See Also:
enqueue(java.lang.Object)
Postcondition:
the value is added to the tail of the structure

enqueue

void enqueue(java.lang.Object value)
Add a value to the tail of the queue.

Parameters:
value - The value to be added.
Postcondition:
the value is added to the tail of the structure

remove

java.lang.Object remove()
Remove a value form the head of the queue.

Specified by:
remove in interface Linear
Returns:
The value actually removed.
See Also:
dequeue()
Precondition:
the queue is not empty
Postcondition:
the head of the queue is removed and returned

dequeue

java.lang.Object dequeue()
Remove a value from the head of the queue.

Returns:
The value removed from the queue.
Precondition:
the queue is not empty
Postcondition:
the head of the queue is removed and returned

getFirst

java.lang.Object getFirst()
Fetch the value at the head of the queue.

Returns:
Reference to the first value of the queue.
Precondition:
the queue is not empty
Postcondition:
the element at the head of the queue is returned

get

java.lang.Object get()
Fetch the value at the head of the queue.

Specified by:
get in interface Linear
Returns:
Reference to the first value of the queue.
Precondition:
the queue is not empty
Postcondition:
the element at the head of the queue is returned

peek

java.lang.Object peek()
Fetch the value at the head of the queue.

Returns:
Reference to the first value of the queue.
Precondition:
the queue is not empty
Postcondition:
the element at the head of the queue is returned

empty

boolean empty()
Returns true iff the queue is empty. Provided for compatibility with java.util.Vector.empty.

Specified by:
empty in interface Linear
Returns:
True iff the queue is empty.
Postcondition:
returns true if and only if the queue is empty

size

int size()
Returns the number of elements in the queue.

Specified by:
size in interface Linear
Specified by:
size in interface Structure
Returns:
number of elements in queue.
Postcondition:
returns the number of elements in the queue