All Packages Class Hierarchy This Package Previous Next Index
Interface jdsl.simple.api.Stack
- public interface Stack
Interface for a stack. A stack is a collection of objects
elements that are inserted and removed according to the last-in
first-out principle.
- Version:
- $Revision: 1.2 $, $Date: 1998/07/02 21:24:51 $
- Author:
- Michael T. Goodrich, Mark Handy, Roberto Tamassia
- See Also:
- StackEmptyException, Queue, Deque
-
isEmpty()
-
Tests if the stack is empty
-
pop()
-
Remove the top element.
-
push(Object)
-
Insert an element at the top.
-
size()
-
Return the number of elements.
-
top()
- Inspect the top element, without removing it or otherwise
modifying the stack.
size
public abstract int size()
- Return the number of elements.
- Returns:
- number of elements in the stack.
isEmpty
public abstract boolean isEmpty()
- Tests if the stack is empty
- Returns:
-
true
if the stack is empty, false
otherwise.
top
public abstract Object top() throws StackEmptyException
- Inspect the top element, without removing it or otherwise
modifying the stack.
- Returns:
- top element in the stack.
- Throws: StackEmptyException
- If this stack is empty.
push
public abstract void push(Object element)
- Insert an element at the top.
- Parameters:
- element - new element to be inserted.
pop
public abstract Object pop() throws StackEmptyException
- Remove the top element.
- Returns:
- element removed.
- Throws: StackEmptyException
- if this stack is empty
All Packages Class Hierarchy This Package Previous Next Index