All Packages Class Hierarchy This Package Previous Next Index
Class DataStructures.StackAr
java.lang.Object
|
+----DataStructures.StackAr
- public class StackAr
- extends Object
Array-based implementation of the stack.
StackAr()
- Construct the stack.
StackAr(int)
- Construct the stack.
isEmpty()
- Test if the stack is logically empty.
isFull()
- Test if the stack is logically full.
main(String[])
-
makeEmpty()
- Make the stack logically empty.
pop()
- Remove the most recently inserted item from the stack.
push(Object)
- Insert a new item into the stack, if not already full.
top()
- Get the most recently inserted item in the stack.
topAndPop()
- Return and remove most recently inserted item from the stack.
StackAr
public StackAr()
- Construct the stack.
StackAr
public StackAr(int capacity)
- Construct the stack.
- Parameters:
- capacity - the capacity.
isEmpty
public boolean isEmpty()
- Test if the stack is logically empty.
- Returns:
- true if empty, false otherwise.
isFull
public boolean isFull()
- Test if the stack is logically full.
- Returns:
- true if full, false otherwise.
makeEmpty
public void makeEmpty()
- Make the stack logically empty.
top
public Object top()
- Get the most recently inserted item in the stack.
Does not alter the stack.
- Returns:
- the most recently inserted item in the stack, or null, if empty.
pop
public void pop() throws Underflow
- Remove the most recently inserted item from the stack.
- Throws:
Underflow
- if stack is already empty.
push
public void push(Object x) throws Overflow
- Insert a new item into the stack, if not already full.
- Parameters:
- x - the item to insert.
- Throws:
Overflow
- if stack is already full.
topAndPop
public Object topAndPop()
- Return and remove most recently inserted item from the stack.
- Returns:
- most recently inserted item, or null, if stack is empty.
main
public static void main(String[] args)
All Packages Class Hierarchy This Package Previous Next Index