structure
Class AbstractStack
java.lang.Object
structure.AbstractStructure
structure.AbstractLinear
structure.AbstractStack
- All Implemented Interfaces:
- Linear, Stack, Structure
- Direct Known Subclasses:
- StackArray, StackList, StackVector
public abstract class AbstractStack
- extends AbstractLinear
- implements Stack
An abstract structure describing a Last-In, First-Out structure.
Stacks are typically used to store the state of a recursively
solved problem.
Method Summary |
Object |
getFirst()
Deprecated. Please use method get, rather than getFirst! |
Object |
peek()
Fetch a reference to the top element of the stack. |
Object |
pop()
Remove an element from the top of the stack. |
void |
push(Object item)
Add an element from the top of the stack. |
AbstractStack
public AbstractStack()
push
public void push(Object item)
- Add an element from the top of the stack.
- Specified by:
push
in interface Stack
- Parameters:
item
- The element to be added to the stack top.
pop
public Object pop()
- Remove an element from the top of the stack.
- Specified by:
pop
in interface Stack
- Returns:
- The item removed from the top of the stack.
getFirst
public Object getFirst()
- Deprecated. Please use method get, rather than getFirst!
- Fetch a reference to the top element of the stack.
- Specified by:
getFirst
in interface Stack
- Returns:
- A reference to the top element of the stack.
peek
public Object peek()
- Fetch a reference to the top element of the stack.
Provided for compatibility with java.util.Stack.
- Specified by:
peek
in interface Stack
- Returns:
- A reference to the top element of the stack.