Standard Queue Operations
- boolean empty()
- void makeEmpty()
- E enqueue (E item)
- E dequeue()
- E peek()
java.util.Queue<E> Interface
- boolean offer (E item). Inserts the item if possible.
- E element(). Retrieves the head of the queue. Throws
NuSuchElementException if empty.
- E remove(). Removes the head of the queue.
Throws NoSuchElementException if empty.
- E peek(). Retrieves the head of the queue. Returns null if empty.
- E poll(). Removes the head of the queue. Returns null if empty.
Note: this interface is implemented by LinkedList<E>.
Many CS Applications
- Print Queue
- CPU Queue
- Networking Packet Queues
- Breadth-First Search
- etc.
Lecture Code
This code demonstrated the adapter class concept.