public class ArrayBasedStack extends java.lang.Object implements StackInterface
Constructor and Description |
---|
ArrayBasedStack(int size)
Initialize a stack (with a given size)
|
Modifier and Type | Method and Description |
---|---|
boolean |
isEmpty()
Check whether the stack is empty
|
int |
pop()
Removes the value at the top of this stack and returns that value as the value of this function.
|
void |
push(int value)
Pushes a value onto the top of this stack.
|
void |
reset()
Reset the array: all elements are removed (set to 0)
|
int |
size()
Returns the numbers of elements stored in the stack.
|
int |
top()
Returns the value at the top of this stack (with deletion).
|
java.lang.String |
toString()
Returns a string representing the elements stored in the stack
|
public ArrayBasedStack(int size)
public void push(int value)
push
in interface StackInterface
public int pop()
pop
in interface StackInterface
public int top()
top
in interface StackInterface
public int size()
size
in interface StackInterface
public boolean isEmpty()
isEmpty
in interface StackInterface
public void reset()
reset
in interface StackInterface
public java.lang.String toString()
toString
in class java.lang.Object