structure
Class AbstractQueue
java.lang.Object
structure.AbstractStructure
structure.AbstractLinear
structure.AbstractQueue
- All Implemented Interfaces:
- Linear, Queue, Structure
- Direct Known Subclasses:
- QueueArray, QueueList, QueueVector
public abstract class AbstractQueue
- extends AbstractLinear
- implements Queue
An abstract structure describing a First-In, First-Out structure.
Queues are typically used to store the state of a buffered object.
Method Summary |
java.lang.Object |
dequeue()
Remove a value form the head of the queue. |
void |
enqueue(java.lang.Object item)
Add a value to the tail 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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
AbstractQueue
public AbstractQueue()
enqueue
public void enqueue(java.lang.Object item)
- Add a value to the tail of the queue.
- Specified by:
enqueue
in interface Queue
- Parameters:
value
- The value added.- Postcondition:
- the value is added to the tail of the structure
dequeue
public java.lang.Object dequeue()
- Remove a value form the head of the queue.
- Specified by:
dequeue
in interface Queue
- Returns:
- The value actually removed.
- Precondition:
- the queue is not empty
- Postcondition:
- the head of the queue is removed and returned
getFirst
public java.lang.Object getFirst()
- Fetch the value at the head of the queue.
- Specified by:
getFirst
in interface 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
peek
public java.lang.Object peek()
- Fetch the value at the head of the queue.
- Specified by:
peek
in interface 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