|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Specifications for a (pushdown) stack, the semi-formal notation for specifications appears on the notation page.
A stack S is
|
| Method Summary | |
boolean |
isEmpty()
Stack does not change, returns true iff the stack is empty. |
java.lang.Object |
pop()
Decrease the size of the stack by one by removing and returning the object at the top. |
void |
push(java.lang.Object item)
Increase the size of the stack by one by placing item as the new top of the stack. |
java.lang.Object |
topOf()
Stack does not change, returns the reference to the top object in the stack. |
java.lang.String |
toString()
Returns a string representation of the stack. |
| Method Detail |
public boolean isEmpty()
|
S'=S Return S==() |
public java.lang.Object topOf()
|
S!=() S'=S Return an-1 |
Assertion - When stack is emptypublic void push(java.lang.Object item)
| S'=(S, obj) |
item - The new top of stackpublic java.lang.Object pop()
|
S!=() S = (S', an-1) Return: an-1 |
Assertion - When stack is emptypublic java.lang.String toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||