Package org.eclipse.m2m.atl.emftvm.util
Class Stack
java.lang.Object
org.eclipse.m2m.atl.emftvm.util.Stack
EMFTVM stack.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
dup()
Duplicates top stack value onto stack.void
dupX1()
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) Popsn
elements off the stack.<T> T[]
pop
(int n, T[] result) Popsn
elements off the stack.void
popv()
Pops an element off the stack without returning it.void
Pushesvalue
onto the stack.boolean
Returnstrue
iff the stack is empty.void
swap()
Swaps top two values on the stack.void
swapX1()
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
Pushesvalue
onto 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
Popsn
elements off the stack.- Parameters:
n
- the number of elements to pop- Returns:
- the top
n
element of the stack.
-
pop
public <T> T[] pop(int n, T[] result) Popsn
elements off the stack.- Parameters:
n
- the number of elements to popresult
- the target array- Returns:
- the top
n
element of the stack, inresult
.
-
peek
Returns the top element of the stack.- Returns:
- the top element of the stack.
-
stackEmpty
public boolean stackEmpty()Returnstrue
iff the stack is empty.- Returns:
true
iff 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.
-