Class Stack


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

      Constructors 
      Constructor Description
      Stack​(int maxStack)
      Creates a new 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)
      Pops n elements off the stack.
      <T> T[] pop​(int n, T[] result)
      Pops n elements off the stack.
      void popv()
      Pops an element off the stack without returning it.
      void push​(java.lang.Object value)
      Pushes value onto the stack.
      boolean stackEmpty()
      Returns true 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.
      • Methods inherited from class java.lang.Object

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

      • Stack

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

      • push

        public void push​(java.lang.Object value)
        Pushes value 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)
        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 java.lang.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.