java.lang.Object
org.parboiled.common.IntArrayStack
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Empties the stack.voidgetElements(int[] destArray, int destStartIndex) Copies all elements currently on the stack into the given array.booleanisEmpty()Tests if the stack is empty.intpeek()Returns the item at the top of the stack without removing it.intpop()Removes the most recently inserted item from the stack.voidpush(int x) Pushes a new item onto the stack.intsize()Returns the number of element currently on the stack.int[]toArray()
-
Constructor Details
-
IntArrayStack
public IntArrayStack()
-
-
Method Details
-
isEmpty
Tests if the stack is empty.- Returns:
- true if empty, false otherwise.
-
size
Returns the number of element currently on the stack.- Returns:
- the number of element currently on the stack
-
getElements
Copies all elements currently on the stack into the given array.- Parameters:
destArray- the arraydestStartIndex- the index to start copying into
-
toArray
- Returns:
- all elements in a new array.
-
clear
Empties the stack. -
peek
Returns the item at the top of the stack without removing it.- Returns:
- the most recently inserted item in the stack.
- Throws:
IntArrayStack.UnderflowException- if the stack is empty.
-
pop
Removes the most recently inserted item from the stack.- Returns:
- the top stack item
- Throws:
IntArrayStack.UnderflowException- if the stack is empty.
-
push
Pushes a new item onto the stack.- Parameters:
x- the item to add.
-