|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectm865.datastructures.AbstractStack
m865.datastructures.StackLL
This class implements a Stack using a simple Linked List.
Nested Class Summary | |
protected class |
StackLL.Link
The Linked List is built from a simple forward link. |
class |
StackLL.StackLLIterator
An iterator for an ArrayList stack. |
Field Summary | |
protected StackLL.Link |
top
The Linked List starts with this link. |
Fields inherited from class m865.datastructures.AbstractStack |
hash |
Constructor Summary | |
|
StackLL()
Constructs a stack which uses a simple Linked List. |
|
StackLL(java.util.Collection c)
Constructs a stack which is initialized with the objects in the specified collection |
protected |
StackLL(int hash,
StackLL.Link topOfLinkedList)
Constructs a stack with a specified hash code and a specified linked list. |
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. |
boolean |
isEmpty()
Determines whether the stack is empty. |
java.util.Iterator |
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 StackLL class to insure that the elementary functions are correct. |
java.lang.Object |
peek()
Returns the object on the top of the stack. |
java.lang.Object |
pop()
Removes and returns the object on the top of the stack. |
void |
push(java.lang.Object obj)
Pushes an 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, remove, removeAll, retainAll, toArray, toArray, updateHashCode |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected StackLL.Link top
Constructor Detail |
public StackLL()
public StackLL(java.util.Collection c)
c
- the collection of objects to be initially pushed
onto this stack.protected StackLL(int hash, StackLL.Link topOfLinkedList)
hash
- the hash codetopOfLinkedList
- the top of the linked list.Method Detail |
public void push(java.lang.Object obj)
push
in class AbstractStack
obj
- the object to be placed on the top of the stack.public java.lang.Object pop()
pop
in class AbstractStack
public java.lang.Object peek()
peek
in class AbstractStack
public void clear()
public java.lang.Object clone()
public boolean isEmpty()
isEmpty
in interface java.util.Collection
isEmpty
in class AbstractStack
public java.util.Iterator iterator()
public int size()
public java.lang.String toString()
toString
in class AbstractStack
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 |