Queue
Queue is a collection that usually stores element for later use. You can put elements into a queue and you can pull them out. An implementation may specify the given order, that may be first in first out (FIFO) or last in first out (LIFO) or some priority based ordering.
On a queue, you can invoke the add method to add an element, remove to remove the head element, and the element method to access the head element without removing it from the queue. The add method will throw an exception when there is a capacity problem and the element cannot be added to the queue. When the queue is empty, and there is no head element, the element and remove methods throw exception.
As exceptions can only be used in exceptional cases, and the calling ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access