Top Description Fields Constructors Methods
org.glassfish.jaxb.runtime.v2.util

public final Class CollisionCheckStack<E>

extends AbstractList<E>
Class Inheritance
Imports
java.util.AbstractList, .Arrays, .List, .Stack

Stack-like data structure that allows the following efficient operations:
  1. Push/pop operation.
  2. 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

Modifier and TypeField and Description
private Object[]
private final int[]
private boolean
private int[]
private int
private boolean
useIdentity

True if the check shall be done by using the object identity.

Inherited from java.util.AbstractList:
modCount

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
public boolean
private boolean
findDuplicate(E o, int hash)

public E
get(int index)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Returns the element at the specified position in this list.

public String
getCycleString()

String that represents the cycle.

public boolean
public boolean
private int
public E
peek()

Returns the top of the stack.

public E
pop()

Pops an object from the stack

public boolean

Returns:

true if this object has already been pushed
push
(E o)

Pushes a new object to the stack.

public void
pushNocheck(E o)

Pushes a new object to the stack without making it participate with the collision check.

public void
reset()

Clears all the contents in the stack.

public void
setUseIdentity(boolean useIdentity)

Set to false to use Object#equals(Object) to detect cycles.

public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Returns the number of elements in this list.

Inherited from java.util.AbstractList:
addaddaddAllclearequalshashCodeindexOfiteratorlastIndexOflistIteratorlistIteratorremoveremoveRangesetsubList

Field Detail

databack to summary
private Object[] data
initialHashback to summary
private final int[] initialHash
latestPushResultback to summary
private boolean latestPushResult
nextback to summary
private int[] next
sizeback to summary
private int size
useIdentityback to summary
private boolean useIdentity

True if the check shall be done by using the object identity. False if the check shall be done with the equals method.

Constructor Detail

CollisionCheckStackback to summary
public CollisionCheckStack()

Method Detail

expandCapacityback to summary
private void expandCapacity()
findDuplicateback to summary
public boolean findDuplicate(E o)
findDuplicateback to summary
private boolean findDuplicate(E o, int hash)
getback to summary
public E get(int index)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Doc from java.util.AbstractList.get.

Returns the element at the specified position in this list.

Annotations
@Override
getCycleStringback to summary
public String getCycleString()

String that represents the cycle.

getLatestPushResultback to summary
public boolean getLatestPushResult()
getUseIdentityback to summary
public boolean getUseIdentity()
hashback to summary
private int hash(Object o)
peekback to summary
public E peek()

Returns the top of the stack.

popback to summary
public E pop()

Pops an object from the stack

pushback to summary
public boolean push(E o)

Pushes a new object to the stack.

Returns:boolean

true if this object has already been pushed

pushNocheckback to summary
public void pushNocheck(E o)

Pushes a new object to the stack without making it participate with the collision check.

resetback to summary
public void reset()

Clears all the contents in the stack.

setUseIdentityback to summary
public void setUseIdentity(boolean useIdentity)

Set to false to use Object#equals(Object) to detect cycles. This method can be only used when the stack is empty.

sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Doc from java.util.List.size.

Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Annotations
@Override