Class FixedSizeIntegerQueue

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

public final class FixedSizeIntegerQueue extends 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.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
     
    private int
     
    private final int[]
     
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    void
    Empty the queue.
    void
    enqueue(int e)
    Add an element to the queue.
    boolean
    Check if the queue has any items.
    int
    Poll the first element from the queue.
    int
    Returns the number of items in the queue.
    Returns a textual representation of the queue.

    Methods inherited from class java.lang.Object

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

    • vs

      private final int[] vs
    • i

      private int i
    • n

      private int n
  • 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 String toString()
      Returns a textual representation of the queue.
      Overrides:
      toString in class Object
      Returns:
      a textual representation of the queue.