Interface Queue<Item>

Type Parameters:
Item - the item type
All Superinterfaces:
Container<Item>, dsa.lib.DSAInterface, 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 Summary

    Modifier and Type
    Method
    Description
    Dequeue (remove and return) the given item from the front.
    void
    enqueue(Item item)
    Enqueue (insert) the given item to the back.
    Get the item at the front.

    Methods inherited from interface dsa.lab02.base.Container

    contains, isEmpty, items, iterator, size, toString

    Methods inherited from interface dsa.lib.DSAInterface

    toDebugString

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • 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)