|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--csc241.samples.Stack.dynamicStack
~mohammad/public_html/classes/csc241/Stack/dynamicStack.java
This version implements Stack using a linked list; and is never full.
The concept here is unlike anything you have done before; it is
important to understand object refernencing.
A Stack has two components:
Constructor Summary | |
dynamicStack()
construct a dynamicStack |
Method Summary | |
boolean |
empty()
return true if stack is empty, otherwise, return false. topElement_ being null implies the stack is empty. |
boolean |
full()
always return false. |
csc241.samples.Stack.Stack |
pop()
remove an element from the top of the stack. Simply, return restOfStack_. |
csc241.samples.Stack.Stack |
push(java.lang.Object x)
add an element to the top of the stack. |
java.lang.Object |
top()
return the element on top of the stack. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public dynamicStack()
Method Detail |
public boolean empty()
empty
in interface Stack
public boolean full()
full
in interface Stack
public csc241.samples.Stack.Stack push(java.lang.Object x) throws stackException
push
in interface Stack
-
- Exception if stack is full.
stackException
public csc241.samples.Stack.Stack pop() throws stackException
pop
in interface Stack
-
- Exception if stack is empty.
stackException
public java.lang.Object top()
top
in interface Stack
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |