it.unimi.dsi.fastutil
Class AbstractStack
java.lang.Object
it.unimi.dsi.fastutil.AbstractStack
- All Implemented Interfaces:
- Stack
- Direct Known Subclasses:
- AbstractBooleanStack, AbstractByteStack, AbstractCharStack, AbstractDoubleStack, AbstractFloatStack, AbstractIntStack, AbstractLongStack, AbstractShortStack
- public abstract class AbstractStack
- extends Object
- implements Stack
An abstract class providing basic methods for implementing the Stack interface.
This class just defines Stack.top() as peek(0), and
Stack.peek(int) as throwing an UnsupportedOperationException.
Subclasses of this class may choose to implement just Stack.push(Object),
Stack.pop() and Stack.isEmpty(), or (but this is not
required) go farther and implement Stack.top(), or even Stack.peek(int).
|
Method Summary |
Object |
peek(int i)
Peeks at an element on the stack (optional operation). |
Object |
top()
Peeks at the top of the stack (optional operation). |
AbstractStack
public AbstractStack()
top
public Object top()
- Description copied from interface:
Stack
- Peeks at the top of the stack (optional operation).
- Specified by:
top in interface Stack
- Returns:
- the top of the stack.
peek
public Object peek(int i)
- Description copied from interface:
Stack
- Peeks at an element on the stack (optional operation).
- Specified by:
peek in interface Stack
- Returns:
- the
i-th element on the stack; 0 represents the top.