|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Stack<K>
A stack.
A stack must provide the classical push(Object)
and
pop()
operations, but may be also peekable
to some extent: it may provide just the top()
function,
or even a more powerful peek(int)
method that provides
access to all elements on the stack (indexed from the top, which
has index 0).
Method Summary | |
---|---|
boolean |
isEmpty()
Checks whether the stack is empty. |
K |
peek(int i)
Peeks at an element on the stack (optional operation). |
K |
pop()
Pops the top off the stack. |
void |
push(K o)
Pushes the given object on the stack. |
K |
top()
Peeks at the top of the stack (optional operation). |
Method Detail |
---|
void push(K o)
o
- the object that will become the new top of the stack.K pop()
NoSuchElementException
- if the stack is empty.boolean isEmpty()
K top()
NoSuchElementException
- if the stack is empty.K peek(int i)
i
-th element on the stack; 0 represents the top.
IndexOutOfBoundsException
- if the designated element does not exist..
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |