All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class structure.StackList

java.lang.Object
    |
    +----structure.StackList

public class StackList
extends Object
implements Stack
An implementation of a stack, based on lists. The head of the stack is stored at the head of the list.


Constructor Index

 o StackList()
Construct an empty stack.

Method Index

 o add(Object)
Add a value to the top of the stack.
 o clear()
Remove all elements from the stack.
 o empty()
Determine if the stack is empty.
 o isEmpty()
Determine if the stack is empty.
 o peek()
Get a reference to the top value in the stack.
 o pop()
Remove a value from the top of the stack.
 o push(Object)
Value is added to the top of the stack.
 o remove()
Remove a value from the top of the stack.
 o size()
Determine the number of elements in the stack.
 o toString()
Construct a string representation of the stack.

Constructors

 o StackList
public StackList()
Construct an empty stack.

Postcondition:
constructs a new stack, based on lists

Methods

 o clear
public void clear()
Remove all elements from the stack.

Postcondition:
removes all elements from stack

 o empty
public boolean empty()
Determine if the stack is empty. Provided for compatibility with java.util.Stack.empty.

Postcondition:
returns true iff the stack is empty

Returns:
True iff the stack is empty.
See Also:
isEmpty
 o isEmpty
public boolean isEmpty()
Determine if the stack is empty.

Postcondition:
returns true iff the stack is empty

Returns:
True iff the stack is empty.
See Also:
empty
 o peek
public Object peek()
Get a reference to the top value in the stack.

Precondition:
stack is not empty
Postcondition:
returns the top element (most recently pushed) from stack

Returns:
A reference to the top element of the top of the stack.
 o add
public void add(Object value)
Add a value to the top of the stack.

Postcondition:
adds an element to stack. Will be next element popped if no intervening push

Parameters:
item - The value to be added.
See Also:
push
 o push
public void push(Object value)
Value is added to the top of the stack.

Postcondition:
adds an element to stack. will be next element popped if no intervening push

Parameters:
item - The value to be added.
 o remove
public Object remove()
Remove a value from the top of the stack.

Precondition:
stack is not empty
Postcondition:
removes and returns the top element from stack.

Returns:
The value removed from the top of the stack.
See Also:
pop
 o pop
public Object pop()
Remove a value from the top of the stack.

Precondition:
stack is not empty
Postcondition:
removes and returns the top element from stack.

Returns:
The value removed.
 o size
public int size()
Determine the number of elements in the stack.

Postcondition:
returns the size of the stack

Returns:
The number of values within the stack.
 o toString
public String toString()
Construct a string representation of the stack.

Postcondition:
returns a string representation of stack

Returns:
A string representing the stack.
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index