java.lang.Object
org.jgrapht.alg.util.FixedSizeIntegerQueue
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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.toString()
Returns a textual representation of the queue.
-
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
Returns a textual representation of the queue.
-