All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class structure.StackVector

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

public class StackVector
extends Object
implements Stack
An implementation of stacks using Vectors.


Constructor Index

 o StackVector()
Construct an empty stack.
 o StackVector(int)
Construct a stack with initial capacity Vector will grow if the stack fills vector.

Method Index

 o add(Object)
Add an element from the top of the stack.
 o clear()
Remove all elements from stack.
 o empty()
Returns true iff the stack is empty.
 o isEmpty()
Returns tree iff the stack is empty.
 o peek()
Fetch a reference to the top element of the stack.
 o pop()
Remove an element from the top of the stack.
 o push(Object)
Add an element to top of stack.
 o remove()
Remove an element from the top of the stack.
 o size()
Determine the number of elements in stack.
 o toString()
Construct a string representation of stack.

Constructors

 o StackVector
public StackVector()
Construct an empty stack.

Postcondition:
an empty stack is created

 o StackVector
public StackVector(int size)
Construct a stack with initial capacity Vector will grow if the stack fills vector.

Postcondition:
an empty stack with initial capacity of size is created

Parameters:
size - The initial capacity of the vector.

Methods

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

Postcondition:
item is added to stack will be popped next if no intervening add

Parameters:
item - The element to be added to the stack top.
See Also:
push
 o push
public void push(Object item)
Add an element to top of stack.

Postcondition:
item is added to stack will be popped next if no intervening push

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

Precondition:
stack is not empty
Postcondition:
most recently added item is removed and returned

Returns:
The item removed from the top of the stack.
See Also:
pop
 o pop
public Object pop()
Remove an element from the top of the stack.

Precondition:
stack is not empty
Postcondition:
most recently pushed item is removed and returned

Returns:
A reference to the removed element.
 o peek
public Object peek()
Fetch a reference to the top element of the stack.

Precondition:
stack is not empty
Postcondition:
top value (next to be popped) is returned

Returns:
A reference to the top element of the stack.
 o empty
public boolean empty()
Returns true iff the stack is empty. Provided for compatibility with java.util.Vector.empty.

Postcondition:
returns true if and only if the stack is empty

Returns:
True iff the stack is empty.
See Also:
isEmpty
 o size
public int size()
Determine the number of elements in stack.
Postcondition:
returns the number of elements in stack

Returns:
The number of elements in stack.
 o clear
public void clear()
Remove all elements from stack.

Postcondition:
removes all elements from stack

 o isEmpty
public boolean isEmpty()
Returns tree iff the stack is empty.

Postcondition:
returns true if and only iff the stack is empty

Returns:
True iff the stack is empty.
See Also:
empty
 o toString
public String toString()
Construct a string representation of 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