Package org.jacop.jasat.utils.structures
Class IntStack
java.lang.Object
org.jacop.jasat.utils.structures.IntStack
Special class for unboxed int stack
- Version:
- 4.8
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
private void
ensureCapacity
(int n) ensure the stack can contains at least n elementsboolean
isEmpty()
int
peek()
returns, without removing, the top elementint
pop()
returns the top of the stack and removes it from the stackvoid
push
(int n) pushes the int on the stackint
size()
toString()
-
Field Details
-
array
public int[] array -
currentIndex
public int currentIndex -
pool
-
-
Constructor Details
-
IntStack
-
-
Method Details
-
clear
public void clear() -
isEmpty
public boolean isEmpty()- Returns:
- true if the stack is empty
-
size
public int size()- Returns:
- the number of elements of the stack
-
push
public void push(int n) pushes the int on the stack- Parameters:
n
- the element to push
-
pop
public int pop()returns the top of the stack and removes it from the stack- Returns:
- the top element
-
peek
public int peek()returns, without removing, the top element- Returns:
- the top element
-
ensureCapacity
private void ensureCapacity(int n) ensure the stack can contains at least n elements- Parameters:
n
- the number of elements
-
toString
-