Package org.eclipse.m2m.atl.emftvm.util
Class Stack
java.lang.Object
org.eclipse.m2m.atl.emftvm.util.Stack
EMFTVM stack.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddup()Duplicates top stack value onto stack.voiddupX1()Pops top two values from stack, pushes top value, then pushes original two values back.peek()Returns the top element of the stack.pop()Pops an element off the stack.Object[]pop(int n) Popsnelements off the stack.<T> T[]pop(int n, T[] result) Popsnelements off the stack.voidpopv()Pops an element off the stack without returning it.voidPushesvalueonto the stack.booleanReturnstrueiff the stack is empty.voidswap()Swaps top two values on the stack.voidswapX1()Swaps third value over top two values on the stack.
-
Constructor Details
-
Stack
public Stack(int maxStack) Creates a newStack.- Parameters:
maxStack- the maximum number of slots to allocate for this stack
-
-
Method Details
-
push
Pushesvalueonto the stack.- Parameters:
value- the value to push
-
pop
Pops an element off the stack.- Returns:
- the top element of the stack.
-
popv
public void popv()Pops an element off the stack without returning it. -
pop
Popsnelements off the stack.- Parameters:
n- the number of elements to pop- Returns:
- the top
nelement of the stack.
-
pop
public <T> T[] pop(int n, T[] result) Popsnelements off the stack.- Parameters:
n- the number of elements to popresult- the target array- Returns:
- the top
nelement of the stack, inresult.
-
peek
Returns the top element of the stack.- Returns:
- the top element of the stack.
-
stackEmpty
public boolean stackEmpty()Returnstrueiff the stack is empty.- Returns:
trueiff the stack is empty.
-
dup
public void dup()Duplicates top stack value onto stack. -
dupX1
public void dupX1()Pops top two values from stack, pushes top value, then pushes original two values back. -
swap
public void swap()Swaps top two values on the stack. -
swapX1
public void swapX1()Swaps third value over top two values on the stack.
-