Class ExpressionStack
java.lang.Object
com.blackrook.expression.ExpressionStack
A calculation stack for expression calculation.
- Author:
- Matthew Tropiano
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a stack with a default size.ExpressionStack(int capacity) Creates a context with a default size. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the context.booleanisEmpty()peek()Peeks at a value on the top of the stack.pop()Pops a value off the stack.voidpush(boolean value) Pushes a value onto the stack.voidpush(double value) Pushes a value onto the stack.voidpush(long value) Pushes a value onto the stack.voidpush(ExpressionValue value) Pushes a value onto the stack.intsize()toString()
-
Field Details
-
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITYDefault 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
Pushes a value onto the stack.- Parameters:
value- the value to push.
-
pop
Pops a value off the stack.- Returns:
- the value at the top of the stack, or null if none left.
-
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
-