structure
Interface Stack

All Superinterfaces:
Linear, Structure
All Known Implementing Classes:
AbstractStack, StackArray, StackList, StackVector

public interface Stack
extends Linear

An interface describing a Last-In, First-Out structure. Stacks are typically used to store the state of a recursively solved problem.


Method Summary
 void add(Object item)
          Add an element from the top of the stack.
 boolean empty()
          Returns true iff the stack is empty.
 Object get()
          Fetch a reference to the top element of the stack.
 Object getFirst()
          Fetch a reference to the top element of the stack.
 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 to top of stack.
 Object remove()
          Remove an element from the top of the stack.
 int size()
          Returns the number of elements in the stack.
 
Methods inherited from interface structure.Structure
clear, contains, elements, isEmpty, iterator, remove, values
 

Method Detail

add

void add(Object item)
Add an element from the top of the stack.

Specified by:
add in interface Linear
Specified by:
add in interface Structure
Parameters:
item - The element to be added to the stack top.
See Also:
push(java.lang.Object)

push

void push(Object item)
Add an element to top of stack.

Parameters:
item - The value to be added to the top of the stack.

remove

Object remove()
Remove an element from the top of the stack.

Specified by:
remove in interface Linear
Returns:
The item removed from the top of the stack.
See Also:
pop()

pop

Object pop()
Remove an element from the top of the stack.

Returns:
A reference to the removed element.

get

Object get()
Fetch a reference to the top element of the stack.

Specified by:
get in interface Linear
Returns:
A reference to the top element of the stack.

getFirst

Object getFirst()
Fetch a reference to the top element of the stack.

Returns:
A reference to the top element of the stack.

peek

Object peek()
Fetch a reference to the top element of the stack.

Returns:
A reference to the top element of the stack.

empty

boolean empty()
Returns true iff the stack is empty. Provided for compatibility with java.util.Vector.empty.

Specified by:
empty in interface Linear
Returns:
True iff the stack is empty.

size

int size()
Returns the number of elements in the stack.

Specified by:
size in interface Linear
Specified by:
size in interface Structure
Returns:
number of elements in stack.