|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectm865.datastructures.AbstractStack
Abstract class for the stack data structure. It implements the push, pop and convenience methods. The optional methods of the Collections interface, which would allow the stack integrity to be violated are not implemented and throw an UnsupportedOperation exception.
Field Summary | |
protected int |
hash
The cached value of the hash code for the stack. |
Constructor Summary | |
AbstractStack()
|
Method Summary | |
boolean |
add(java.lang.Object obj)
Pushes an object onto the top of the stack. |
boolean |
addAll(java.util.Collection c)
Pushes each object of the specified collection onto the stack. |
boolean |
contains(java.lang.Object obj)
Determines if the specified object is in the stack. |
boolean |
containsAll(java.util.Collection c)
Determines if the specified collection is contained in the stack. |
protected void |
downdateHashCode(java.lang.Object obj)
Downdates the hash code for this stack |
boolean |
equals(java.lang.Object obj)
The test for equality. |
int |
hashCode()
Returns the value of the hash code for this stack. |
boolean |
isEmpty()
Determines whether the stack is empty. |
abstract java.lang.Object |
peek()
Returns the object on the top of the stack. |
abstract java.lang.Object |
pop()
Removes and returns the object on the top of the stack. |
abstract void |
push(java.lang.Object obj)
Pushes an object onto the top of the stack. |
boolean |
remove(java.lang.Object obj)
This is an optional method of the Collection Interface. |
boolean |
removeAll(java.util.Collection c)
This is an optional method of the Collection Interface. |
boolean |
retainAll(java.util.Collection c)
This is an optional method of the Collection Interface. |
java.lang.Object[] |
toArray()
Creates an array containing the objects in this stack. |
java.lang.Object[] |
toArray(java.lang.Object[] a)
Creates an array containing the objects in this stack. |
java.lang.String |
toString()
List the objects in the stack |
protected void |
updateHashCode(java.lang.Object obj)
Updates the hash code for this stack |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Collection |
clear, iterator, size |
Field Detail |
protected int hash
Constructor Detail |
public AbstractStack()
Method Detail |
public abstract void push(java.lang.Object obj)
obj
- the object to be placed on the top of the stack.public abstract java.lang.Object pop()
public abstract java.lang.Object peek()
public boolean add(java.lang.Object obj)
add
in interface java.util.Collection
obj
- the object to be placed on the top of the stack.
public boolean addAll(java.util.Collection c)
addAll
in interface java.util.Collection
c
- the collection of objects to be placed on the stack.
public boolean contains(java.lang.Object obj)
contains
in interface java.util.Collection
obj
- the object to be found in the stack.
public boolean containsAll(java.util.Collection c)
containsAll
in interface java.util.Collection
c
- the collection of objects to be found in the stack.
public boolean equals(java.lang.Object obj)
equals
in interface java.util.Collection
obj
- the object which may be equal to this stack.
public int hashCode()
hashCode
in interface java.util.Collection
protected void updateHashCode(java.lang.Object obj)
obj
- the object being added to the stackprotected void downdateHashCode(java.lang.Object obj)
obj
- the object being removed from the stackpublic boolean isEmpty()
isEmpty
in interface java.util.Collection
public boolean remove(java.lang.Object obj)
remove
in interface java.util.Collection
obj
- the object to be removed.
public boolean removeAll(java.util.Collection c)
removeAll
in interface java.util.Collection
c
- the collection of objects to be removed.
public boolean retainAll(java.util.Collection c)
retainAll
in interface java.util.Collection
c
- the collection of objects to be retained.
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection
public java.lang.Object[] toArray(java.lang.Object[] a)
toArray
in interface java.util.Collection
a
- an array of objects whose run type is compatible with all the
objects in the stack.
public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |