Package com.sun.xml.bind.v2.util
Class CollisionCheckStack<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
com.sun.xml.bind.v2.util.CollisionCheckStack<E>
- All Implemented Interfaces:
Iterable<E>,Collection<E>,List<E>
Stack-like data structure that allows the following efficient operations:
- Push/pop operation.
- Duplicate check. When an object that's already in the stack is pushed, this class will tell you so.
Object equality is their identity equality.
This class implements List for accessing items in the stack,
but List methods that alter the stack is not supported.
- Author:
- Kohsuke Kawaguchi
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanfindDuplicate(E o) get(int index) String that represents the cycle.booleanbooleanpeek()Returns the top of the stack.pop()Pops an object from the stackbooleanPushes a new object to the stack.voidpushNocheck(E o) Pushes a new object to the stack without making it participate with the collision check.voidreset()Clears all the contents in the stack.voidsetUseIdentity(boolean useIdentity) Set to false to useObject.equals(Object)to detect cycles.intsize()Methods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
Constructor Details
-
CollisionCheckStack
public CollisionCheckStack()
-
-
Method Details
-
setUseIdentity
public void setUseIdentity(boolean useIdentity) Set to false to useObject.equals(Object)to detect cycles. This method can be only used when the stack is empty. -
getUseIdentity
public boolean getUseIdentity() -
getLatestPushResult
public boolean getLatestPushResult() -
push
Pushes a new object to the stack.- Returns:
- true if this object has already been pushed
-
pushNocheck
Pushes a new object to the stack without making it participate with the collision check. -
findDuplicate
-
get
-
size
public int size()- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceList<E>- Specified by:
sizein classAbstractCollection<E>
-
pop
Pops an object from the stack -
peek
Returns the top of the stack. -
reset
public void reset()Clears all the contents in the stack. -
getCycleString
String that represents the cycle.
-