Package org.eclipse.m2m.atl.emftvm.util
Class Stack
- java.lang.Object
-
- org.eclipse.m2m.atl.emftvm.util.Stack
-
public final class Stack extends java.lang.Object
EMFTVM stack.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dup()
Duplicates top stack value onto stack.void
dupX1()
Pops top two values from stack, pushes top value, then pushes original two values back.java.lang.Object
peek()
Returns the top element of the stack.java.lang.Object
pop()
Pops an element off the stack.java.lang.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
push(java.lang.Object value)
Pushesvalue
onto the stack.boolean
stackEmpty()
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 Detail
-
Stack
public Stack(int maxStack)
Creates a newStack
.- Parameters:
maxStack
- the maximum number of slots to allocate for this stack
-
-
Method Detail
-
push
public void push(java.lang.Object value)
Pushesvalue
onto the stack.- Parameters:
value
- the value to push
-
pop
public java.lang.Object 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
public java.lang.Object[] pop(int n)
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
public java.lang.Object 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.
-
-