Interface Queue<Item>

Type Parameters:
Item - the item type
All Superinterfaces:
Container<Item>, Iterable<Item>
All Known Implementing Classes:
ArrayQueue, ArrayQueue, LinkedQueue, LinkedQueue

public interface Queue<Item> extends Container<Item>
A queue.

A FIFO (First-In, First-Out) structure where items are added (enqueued) to the back and removed (dequeued) from the front.

  • Method Details

    • enqueue

      void enqueue(Item item)
      Enqueue (insert) the given item to the back.
      Parameters:
      item - the new back item
    • dequeue

      Item dequeue() throws NoSuchElementException
      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)