- 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,clear()
must be invoked.- Author:
- Joris Kinable
-
-
Constructor Summary
Constructors Constructor Description FixedSizeIntegerQueue(int capacity)
Create a queue of fixed size.
-
Method Summary
All Methods Instance Methods Concrete Methods 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.String
toString()
Returns a textual representation of the queue.
-
-
-
Method Detail
-
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.
-
-