|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectm865.datastructures.AbstractStack<T>
m865.datastructures.StackAL<T>
public class StackAL<T>
This class implements a Stack using a dynamic array Version 3.0 incorporates generics
Nested Class Summary | |
---|---|
protected class |
StackAL.StackALIterator<T>
An iterator for an ArrayList stack. |
Field Summary | |
---|---|
protected java.util.ArrayList<T> |
s
The stack is implemented using a dynamic array from java.util.ArrayList |
Fields inherited from class m865.datastructures.AbstractStack |
---|
hash |
Constructor Summary | |
---|---|
|
StackAL()
Constructs a stack whose dynamic array has the default initial size for a ArrayList. |
|
StackAL(java.util.Collection<? extends T> c)
Constructs a stack which is initialized with the objects in the specified collection |
|
StackAL(int capacity)
Constructs a stack whose dynamic array has a specified initial size. |
protected |
StackAL(int hash,
java.util.ArrayList<T> s)
Constructs a stack with a specified hash code and a clone of the specified ArrayList. |
Method Summary | |
---|---|
void |
clear()
Removes all the objects from this stack. |
java.lang.Object |
clone()
The Cloneable Interface indicates that the clone method, which is inherited from Object, is implemented so that a true clone (a true and independent copy) of the object is returned. |
java.util.Iterator<T> |
iterator()
A factory method which returns an Iterator to the collection in this stack. |
static void |
main(java.lang.String[] args)
This main method tests the StackAL class to insure that the elementary functions are correct. |
T |
peek()
Returns the object on the top of the stack. |
T |
pop()
Removes and returns the object on the top of the stack. |
void |
push(T x)
Pushes a type T object onto the top of the stack. |
int |
size()
Determines the size of this stack. |
java.lang.String |
toString()
List the objects in the stack |
Methods inherited from class m865.datastructures.AbstractStack |
---|
add, addAll, contains, containsAll, downdateHashCode, equals, hashCode, isEmpty, remove, removeAll, retainAll, toArray, toArray, updateHashCode |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.util.ArrayList<T> s
Constructor Detail |
---|
public StackAL(int capacity)
capacity
- the initial size of the dynamic array.public StackAL()
public StackAL(java.util.Collection<? extends T> c)
c
- the collection of objects to be initially pushed
onto this stack.protected StackAL(int hash, java.util.ArrayList<T> s)
hash
- the hash codes
- the ArrayList to be cloned.Method Detail |
---|
public void push(T x)
push
in class AbstractStack<T>
x
- the object to be placed on the top of the stack.public T pop()
pop
in class AbstractStack<T>
public T peek()
peek
in class AbstractStack<T>
public void clear()
public java.lang.Object clone()
clone
in class java.lang.Object
public java.util.Iterator<T> iterator()
public int size()
public java.lang.String toString()
toString
in class AbstractStack<T>
public static void main(java.lang.String[] args)
args
- optional command line arguments which will be ignored.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |