Class FixedSizeIntegerQueue

java.lang.Object
org.jgrapht.alg.util.FixedSizeIntegerQueue

public final class FixedSizeIntegerQueue
extends java.lang.Object
Primitive but efficient implementation of a fixed size queue for integers. Note: this queue is not implemented as a ring, so at most $N$ enqueue operations are allowed, where $N$ is the maximum capacity of the queue! After that, queue.clear() must be invoked.
Author:
Joris Kinable
  • Constructor Summary

    Constructors 
    Constructor Description
    FixedSizeIntegerQueue​(int capacity)
    Create a queue of fixed size.
  • Method Summary

    Modifier and Type Method Description
    void clear()
    Empty the queue.
    void enqueue​(int e)
    Add an element to the queue.
    boolean isEmpty()
    Check if the queue has any items.
    int poll()
    Poll the first element from the queue.
    int size()
    Returns the number of items in the queue.
    java.lang.String toString()
    Returns a textual representation of the queue.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • FixedSizeIntegerQueue

      public FixedSizeIntegerQueue​(int capacity)
      Create a queue of fixed size.
      Parameters:
      capacity - size of the queue
  • Method Details

    • enqueue

      public void enqueue​(int e)
      Add an element to the queue.
      Parameters:
      e - element
    • poll

      public int poll()
      Poll the first element from the queue.
      Returns:
      the first element.
    • isEmpty

      public boolean isEmpty()
      Check if the queue has any items.
      Returns:
      true if the queue is empty
    • size

      public int size()
      Returns the number of items in the queue.
      Returns:
      number of items in the queue
    • clear

      public void clear()
      Empty the queue.
    • toString

      public java.lang.String toString()
      Returns a textual representation of the queue.
      Overrides:
      toString in class java.lang.Object
      Returns:
      a textual representation of the queue.