Java Reference
In-Depth Information
to repeatedly remove items from the queue until the desired item reaches the front. If you were to
remove all of a queue's entries one by one, you would get them in chronological order, beginning
with the first item added to the queue.
The queue has no search operation. An entry's value is not relevant to the queue or to the
entry's position within the queue.
10.2
The operation that adds an entry to a queue is traditionally called enqueue (pronounced “N-Q”). The
operation to remove an entry is dequeue ( pronounced “D-Q”). The operation that retrieves the queue's
front entry is called getFront . The following specifications define a set of operations for the ADT queue:
A BSTRACT D ATA T YPE : Q UEUE
D ATA
A collection of objects in chronological order and having the same data type
O PERATIONS
P SEUDOCODE
UML
D ESCRIPTION
enqueue(newEntry)
+enqueue(newEntry: integer): void Task: Adds a new entry to the back of
the queue.
Input: newEntry is the new entry.
Output: None.
dequeue()
+deque(): T
Task: Removes and returns the entry at the
front of the queue.
Input: None.
Output: Returns either the queue's front
entry or, if the queue is empty before
the operation, null .
getFront()
+getFront(): T
Task: Retrieves the queue's front entry
without changing the queue in any way.
Input: None.
Output: Returns either the queue's front entry
or, if the queue is empty, null .
isEmpty()
+isEmpty(): boolean
Task: Detects whether the queue is empty.
Input: None.
Output: Returns true if the queue is empty.
clear()
+clear(): void
Task: Removes all entries from the queue.
Input: None.
Output: None.
 
Search WWH ::




Custom Search