Module com.sun.xml.bind.osgi
Class CollisionCheckStack<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- org.glassfish.jaxb.runtime.v2.util.CollisionCheckStack<E>
-
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,List<E>
public final class CollisionCheckStack<E> extends AbstractList<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, butList
methods that alter the stack is not supported.- Author:
- Kohsuke Kawaguchi
-
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description CollisionCheckStack()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
findDuplicate(E o)
E
get(int index)
String
getCycleString()
String that represents the cycle.boolean
getLatestPushResult()
boolean
getUseIdentity()
E
peek()
Returns the top of the stack.E
pop()
Pops an object from the stackboolean
push(E o)
Pushes a new object to the stack.void
pushNocheck(E o)
Pushes a new object to the stack without making it participate with the collision check.void
reset()
Clears all the contents in the stack.void
setUseIdentity(boolean useIdentity)
Set to false to useObject.equals(Object)
to detect cycles.int
size()
-
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
-
-
-
Method Detail
-
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
public boolean push(E o)
Pushes a new object to the stack.- Returns:
- true if this object has already been pushed
-
pushNocheck
public void pushNocheck(E o)
Pushes a new object to the stack without making it participate with the collision check.
-
findDuplicate
public boolean findDuplicate(E o)
-
get
public E get(int index)
-
size
public int size()
- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceList<E>
- Specified by:
size
in classAbstractCollection<E>
-
pop
public E pop()
Pops an object from the stack
-
peek
public E peek()
Returns the top of the stack.
-
reset
public void reset()
Clears all the contents in the stack.
-
getCycleString
public String getCycleString()
String that represents the cycle.
-
-