|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectca.bcit.cst.comp2526.assign2b.solution.Stack
public class Stack
A Last In First Out (LIFO) data structure that holds integers. This implementation is a fixed sizes stack.
| Field Summary | |
|---|---|
static int |
MIN_SIZE
The smallest possible stack size. |
| Constructor Summary | |
|---|---|
Stack(int size)
Construct an empty stack of the specified size. |
|
| Method Summary | |
|---|---|
int |
pop()
Removes the top item from the stack. |
void |
push(int val)
Push a value onto the top of the stack. |
int |
size()
Get the total number of values the stack can hold. |
int |
topValue()
Return the top value off of the stack withour actually removing it. |
int |
unused()
Get the number of values that can still be pushed onto the stack. |
int |
used()
Get the number of values that are currently on ths stack. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int MIN_SIZE
| Constructor Detail |
|---|
public Stack(int size)
throws java.lang.IllegalArgumentException
size - the maximum size of the stack.
java.lang.IllegalArgumentException - if the size < 1MIN_SIZE| Method Detail |
|---|
public int size()
public int used()
public int unused()
public void push(int val)
throws StackOverflowException
val - the value to push onto the stack.
StackOverflowException - if the unused portion of ths tack is 0.pop(),
topValue(),
unused()
public int pop()
throws StackUnderflowException
StackUnderflowException - if there are no values on the stack.push(int)
public int topValue()
throws StackUnderflowException
StackUnderflowException - if there are no values on the stack.push(int)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||