Package org.chocosolver.util.objects
Class IntCircularQueue
- java.lang.Object
-
- org.chocosolver.util.objects.IntCircularQueue
-
public class IntCircularQueue extends Object
A fix sized circular queue optimized for removing first and last elements. Some few (essential regarding the usage) methods are implemented.
Be aware of the size computation: the modulo operation is not efficient in java. On the other hand, the modulo of powers of 2 can alternatively be expressed as a bitwise AND operation:
x % 2n == x & (2n - 1)
That is why the size of the data is automatically set to the closest greater powers of 2 value.- Since:
- 29 sept. 2010
- Author:
- Charles Prud'homme
-
-
Constructor Summary
Constructors Constructor Description IntCircularQueue(int size)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddFirst(int e)booleanaddLast(int e)voidclear()intget(int index)booleanisEmpty()intpollFirst()This method is the main reason we re-wrote the class.intpollLast()This method is the main reason we re-wrote the class.intsize()
-
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
-
size
public int size()
-
clear
public void clear()
-
get
public int get(int index)
-
addFirst
public boolean addFirst(int e)
-
addLast
public boolean addLast(int e)
-
pollFirst
public int pollFirst()
This method is the main reason we re-wrote the class. It is optimized for removing first and last elements but also allows you to remove in the middle of the list.
-
pollLast
public int pollLast()
This method is the main reason we re-wrote the class. It is optimized for removing first and last elements but also allows you to remove in the middle of the list.
-
-