Class ExpressionStack

java.lang.Object
com.blackrook.expression.ExpressionStack

public class ExpressionStack extends Object
A calculation stack for expression calculation.
Author:
Matthew Tropiano
  • Field Details

    • DEFAULT_CAPACITY

      public static final int DEFAULT_CAPACITY
      Default capacity.
      See Also:
  • Constructor Details

    • ExpressionStack

      public ExpressionStack()
      Creates a stack with a default size.
      See Also:
    • ExpressionStack

      public ExpressionStack(int capacity)
      Creates a context with a default size.
      Parameters:
      capacity - the initial capacity.
  • Method Details

    • push

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

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

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

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

      public ExpressionValue pop()
      Pops a value off the stack.
      Returns:
      the value at the top of the stack, or null if none left.
    • peek

      public ExpressionValue peek()
      Peeks at a value on the top of the stack.
      Returns:
      the value at the top of the stack, or null if none left.
    • clear

      public void clear()
      Clears the context.
    • size

      public int size()
      Returns:
      the stack size.
    • isEmpty

      public boolean isEmpty()
      Returns:
      true if the stack is empty, false if not.
    • toString

      public String toString()
      Overrides:
      toString in class Object