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.
StackList()
- Construct an empty stack.
add(Object)
- Add a value to the top of the stack.
clear()
- Remove all elements from the stack.
empty()
- Determine if the stack is empty.
isEmpty()
- Determine if the stack is empty.
peek()
- Get a reference to the top value in the stack.
pop()
- Remove a value from the top of the stack.
push(Object)
- Value is added to the top of the stack.
remove()
- Remove a value from the top of the stack.
size()
- Determine the number of elements in the stack.
toString()
- Construct a string representation of the stack.
StackList
public StackList()
- Construct an empty stack.
- Postcondition:
- constructs a new stack, based on lists
clear
public void clear()
- Remove all elements from the stack.
- Postcondition:
- removes all elements from stack
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
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
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.
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
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.
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
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.
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.
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