Class DefaultStack

  • All Implemented Interfaces:
    Stack

    public class DefaultStack
    extends java.lang.Object
    implements Stack
    The default implementation of a NamedTable
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) int _count  
      (package private) int _size  
      (package private) static int GROW_SIZE  
      (package private) static int INITIAL_SIZE  
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultStack()  
    • Method Detail

      • push

        public void push​(Stack.ValueAndType valueAndType)
        Pushes a value on the top of the stack so the stack grow.
        Specified by:
        push in interface Stack
        Parameters:
        valueAndType - the value to push to the stack
      • pop

        public java.lang.Object pop()
        Pops the topmost value off the top of the stack so the stack shrinks.
        Specified by:
        pop in interface Stack
        Returns:
        the value that is on the top of the stack
      • getValueAtIndex

        public java.lang.Object getValueAtIndex​(int index)
        Get the value at an index
        Specified by:
        getValueAtIndex in interface Stack
        Parameters:
        index - the index from bottom of the table
        Returns:
        value the new value
      • setValueAtIndex

        public void setValueAtIndex​(int index,
                                    java.lang.Object value)
        Set the value at an index
        Specified by:
        setValueAtIndex in interface Stack
        Parameters:
        index - the index from bottom of the table
        value - the new value
      • getCount

        public int getCount()
        Get the number of items on the stack
        Specified by:
        getCount in interface Stack
        Returns:
        the number of items
      • setCount

        public void setCount​(int newCount)
        Reset the number of items on the stack. This is used when parameters are put on the stack before a call to a module and those parameters needs to be removed when the module returns. The new count must be less than or equal to the current number of items.
        Specified by:
        setCount in interface Stack
        Parameters:
        newCount - the new number of items