Package edu.ksu.cis.viewer
Class GenericStack<E extends Serializable>
java.lang.Object
edu.ksu.cis.viewer.GenericStack<E>
- Type Parameters:
E
- the type of the elements in the stack
- All Implemented Interfaces:
Serializable
A stack built from an immutable
ConsList
. Using an
immutable structure
for the underlying storage allows a shallow clone to be sufficient.- Author:
- Rod Howell (rhowell@ksu.edu)
- See Also:
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
GenericStack
public GenericStack()Constructs an empty Stack.
-
-
Method Details
-
push
Pushes the given Object onto the top of the stack.- Parameters:
obj
- the object to push onto the stack
-
pop
Removes the element from the top of the stack and returns it.- Returns:
- the element removed from the top of the stack
- Throws:
EmptyStackException
- If the stack is empty.
-
empty
public boolean empty()Returns true if the stack is empty.- Returns:
- whether this stack is empty
-
clone
Returns a clone of this stack. Because the underlying structure is immutable, a shallow clone is performed.
-