|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectm865.datastructures.AbstractStack<T>
public abstract class AbstractStack<T>
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. Version 3 incorporates generics Version 3.1 eliminates the Cloneable interface to bring this collection more in line with the Java Collection Framework.
Field Summary | |
---|---|
protected int |
hash
The cached value of the hash code for the stack. |
Constructor Summary | |
---|---|
AbstractStack()
|
Method Summary | ||
---|---|---|
boolean |
add(T x)
Pushes an object onto the top of the stack. |
|
boolean |
addAll(java.util.Collection<? extends T> 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(T x)
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 T |
peek()
Returns the type T object on the top of the stack. |
|
abstract T |
pop()
Removes and returns the type T object on the top of the stack. |
|
abstract void |
push(T x)
Pushes a type T 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. |
|
|
toArray(T[] a)
Creates an array containing the objects in this stack. |
|
java.lang.String |
toString()
List the objects in the stack |
|
protected void |
updateHashCode(T x)
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(T x)
x
- the type T object to be placed on the top of the stack.public abstract T pop()
public abstract T peek()
public boolean add(T x)
add
in interface java.util.Collection<T>
x
- the type T object to be placed on the top of the stack.
public boolean addAll(java.util.Collection<? extends T> c)
addAll
in interface java.util.Collection<T>
c
- the collection of objects to be placed on the stack.
public boolean contains(java.lang.Object obj)
contains
in interface java.util.Collection<T>
obj
- the object to be found in the stack.
public boolean containsAll(java.util.Collection<?> c)
containsAll
in interface java.util.Collection<T>
c
- the collection of objects to be found in the stack.
public boolean equals(java.lang.Object obj)
equals
in interface java.util.Collection<T>
equals
in class java.lang.Object
obj
- the object which may be equal to this stack.
public int hashCode()
hashCode
in interface java.util.Collection<T>
hashCode
in class java.lang.Object
protected void updateHashCode(T x)
x
- the type T object being added to the stackprotected void downdateHashCode(T x)
x
- the type T object being removeed from the stackpublic boolean isEmpty()
isEmpty
in interface java.util.Collection<T>
public boolean remove(java.lang.Object obj)
remove
in interface java.util.Collection<T>
obj
- the object to be removed.
public boolean removeAll(java.util.Collection<?> c)
removeAll
in interface java.util.Collection<T>
c
- the collection of objects to be removed.
public boolean retainAll(java.util.Collection<?> c)
retainAll
in interface java.util.Collection<T>
c
- the collection of objects to be retained.
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection<T>
public <T> T[] toArray(T[] a)
toArray
in interface java.util.Collection<T>
a
- an array of objects whose run type is compatible with all the
objects in the stack.
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |