Package examples

Interface Queue<T>


public interface Queue<T>
  • Method Summary

    Modifier and Type Method Description
    int capacity()
    Returns the number of available spaces left in the queue.
    T dequeue()
    Retrieves and removes the element at the head of the queue.
    void enqueue​(T e)
    Adds an element to the end of the queue.
    T peek()
    Retrieves (but does not remove) the element at the head of the queue.
    void reset()
    Remove all items from the queue and reset the capacity to the initial maximum amount.
  • Method Details

    • capacity

      int capacity()
      Returns the number of available spaces left in the queue.
      Returns:
      how many additional items the queue can hold.
    • enqueue

      void enqueue​(T e)
      Adds an element to the end of the queue.
      Parameters:
      e - the element to add to this collection
      Throws:
      IllegalStateException - if the queue cannot hold additional items
    • dequeue

      T dequeue()
      Retrieves and removes the element at the head of the queue.
      Returns:
      the least-recently added element.
      Throws:
      NoSuchElementException - if the queue is empty
    • peek

      T peek()
      Retrieves (but does not remove) the element at the head of the queue.
      Returns:
      the least-recently added element.
      Throws:
      NoSuchElementException - if the queue is empty
    • reset

      void reset()
      Remove all items from the queue and reset the capacity to the initial maximum amount.