Class Stack

java.lang.Object
org.eclipse.m2m.atl.emftvm.util.Stack

public final class Stack extends Object
EMFTVM stack.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Stack(int maxStack)
    Creates a new Stack.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    dup()
    Duplicates top stack value onto stack.
    void
    Pops top two values from stack, pushes top value, then pushes original two values back.
    Returns the top element of the stack.
    pop()
    Pops an element off the stack.
    pop(int n)
    Pops n elements off the stack.
    <T> T[]
    pop(int n, T[] result)
    Pops n elements off the stack.
    void
    Pops an element off the stack without returning it.
    void
    push(Object value)
    Pushes value onto the stack.
    boolean
    Returns true iff the stack is empty.
    void
    Swaps top two values on the stack.
    void
    Swaps third value over top two values on the stack.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Stack

      public Stack(int maxStack)
      Creates a new Stack.
      Parameters:
      maxStack - the maximum number of slots to allocate for this stack
  • Method Details

    • push

      public void push(Object value)
      Pushes value onto the stack.
      Parameters:
      value - the value to push
    • pop

      public 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 Object[] pop(int n)
      Pops n 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)
      Pops n elements off the stack.
      Parameters:
      n - the number of elements to pop
      result - the target array
      Returns:
      the top n element of the stack, in result.
    • peek

      public Object peek()
      Returns the top element of the stack.
      Returns:
      the top element of the stack.
    • stackEmpty

      public boolean stackEmpty()
      Returns true 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.