Package dsa

Interface Queue<T>

Type Parameters:
T - the type of items in the queue.
All Superinterfaces:
Iterable<T>
All Known Implementing Classes:
LinkedQueue, ResizingArrayQueue

public interface Queue<T> extends Iterable<T>
This interface specifies the API for the queue data structure.
  • Method Summary

    Modifier and Type
    Method
    Description
    Removes and returns the item at the front of this queue.
    void
    enqueue(T item)
    Adds item to the end of this queue.
    boolean
    Returns true if this queue is empty, and false otherwise.
    Returns the item at the front of this queue.
    int
    Returns the number of items in this queue.
    Returns a string representation of this queue.

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator
  • Method Details

    • isEmpty

      boolean isEmpty()
      Returns true if this queue is empty, and false otherwise.
      Returns:
      true if this queue is empty, and false otherwise.
    • size

      int size()
      Returns the number of items in this queue.
      Returns:
      number of items in this queue.
    • enqueue

      void enqueue(T item)
      Adds item to the end of this queue.
      Parameters:
      item - the item.
    • peek

      T peek()
      Returns the item at the front of this queue.
      Returns:
      item at the front of this queue.
    • dequeue

      T dequeue()
      Removes and returns the item at the front of this queue.
      Returns:
      item at the front of this queue.
    • toString

      String toString()
      Returns a string representation of this queue.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this queue.