|
APCS Java Subset | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectap.ListQueue
A simple yet completely functional implementation
of the Queue interface. The interface
is part of the AP subset and is testable. This implementation
is not part of the subset, but is useful in
a classroom setting.
All queue functions execute in O(1) or constant time
amortized over several queue operations. This is because the
underlying storage is java.util.LinkedList which
supports constant time access, add (to end and front), and remove
(from end and front).
This implementation is provided at apcentral.
| Constructor Summary | |
ListQueue()
Constructs an initially empty queue. |
|
| Method Summary | |
java.lang.Object |
dequeue()
Dequeues and returns the first element of the queue. |
void |
enqueue(java.lang.Object x)
Enqueue an element onto the back of this queue. |
boolean |
isEmpty()
Returns true if this queue is empty, otherwise returns false. |
java.lang.Object |
peekFront()
Returns the first element of the queue without dequeuing it. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ListQueue()
| Method Detail |
public void enqueue(java.lang.Object x)
Queue
enqueue in interface Queuex - is the object enqueued onto this queue.public java.lang.Object dequeue()
Queue
dequeue in interface QueueQueue.peekFront()public java.lang.Object peekFront()
Queue
peekFront in interface QueueQueue.dequeue()public boolean isEmpty()
Queue
isEmpty in interface Queue
|
unofficial documentation for the APCS Java Subset | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||