Package dsa.lab03.base
Interface Queue<Item>
- Type Parameters:
Item
- the item type
- All Known Implementing Classes:
ArrayQueue
,ArrayQueue
,LinkedQueue
,LinkedQueue
A queue.
A FIFO (First-In, First-Out) structure where items are added (enqueued) to the back and removed (dequeued) from the front.
-
Method Summary
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
enqueue
Enqueue (insert) the given item to the back.- Parameters:
item
- the new back item
-
dequeue
Dequeue (remove and return) the given item from the front.- Returns:
- the old front item
- Throws:
NoSuchElementException
- if there's no first item to remove (i.e. if this is empty)
-
front
Get the item at the front.- Returns:
- the front item
- Throws:
NoSuchElementException
- if there's no first item to retrieve (i.e. if this is empty)
-