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.

StackVector()
 Construct an empty stack.

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

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

clear()
 Remove all elements from stack.

empty()
 Returns true iff the stack is empty.

isEmpty()
 Returns tree iff the stack is empty.

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

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

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

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

size()
 Determine the number of elements in stack.

toString()
 Construct a string representation of stack.
StackVector
public StackVector()
 Construct an empty stack.
 Postcondition:
 an empty stack is created
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.
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 further add
 Parameters:
 item  The element to be added to the stack top.
 See Also:
 push
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 further push
 Parameters:
 item  The value to be added to the top of the stack.
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
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.
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.
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
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.
clear
public void clear()
 Remove all elements from stack.
 Postcondition:
 removes all elements from stack
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
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