Package org.apache.uima.internal.util
Class CopyOnWriteObjHashSet<T extends FeatureStructure>
- java.lang.Object
-
- org.apache.uima.internal.util.CopyOnWriteObjHashSet<T>
-
- All Implemented Interfaces:
CopyOnWriteIndexPart<T>
public class CopyOnWriteObjHashSet<T extends FeatureStructure> extends java.lang.Object implements CopyOnWriteIndexPart<T>
implements ObjHashSet partially, for iterator use
-
-
Field Summary
Fields Modifier and Type Field Description private ObjHashSet<T>
ohs
private ObjHashSet<T>
original
private int
original_size
-
Constructor Summary
Constructors Constructor Description CopyOnWriteObjHashSet(ObjHashSet<T> original)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
copyToArray(T[] target, int startingIndexInTarget)
Copy FS refs to target from this index partint
find(T obj)
T
get(int index)
For iterator useint
getCapacity()
boolean
isOriginal()
java.util.Iterator<T>
iterator()
void
makeReadOnlyCopy()
Called by index when about to make an updateint
moveTo(FeatureStructure fs)
if the fs is in the set, the iterator should return it.int
moveToNextFilled(int pos)
advance pos until it points to a non 0 or is 1 past endint
moveToPreviousFilled(int pos)
decrement pos until it points to a non 0 or is -1int
size()
java.lang.String
toString()
-
-
-
Field Detail
-
ohs
private ObjHashSet<T extends FeatureStructure> ohs
-
original
private ObjHashSet<T extends FeatureStructure> original
-
original_size
private final int original_size
-
-
Constructor Detail
-
CopyOnWriteObjHashSet
public CopyOnWriteObjHashSet(ObjHashSet<T> original)
-
-
Method Detail
-
makeReadOnlyCopy
public void makeReadOnlyCopy()
Called by index when about to make an update- Specified by:
makeReadOnlyCopy
in interfaceCopyOnWriteIndexPart<T extends FeatureStructure>
-
find
public int find(T obj)
- Parameters:
obj
- the object to find in the table (if it is there)- Returns:
- the position of obj in the table, or -1 if not in the table
-
get
public T get(int index)
For iterator use- Parameters:
index
- a magic number returned by the internal find- Returns:
- the T at that spot, or null if nothing there
-
moveToNextFilled
public int moveToNextFilled(int pos)
advance pos until it points to a non 0 or is 1 past end- Parameters:
pos
- -- Returns:
- updated pos
-
moveToPreviousFilled
public int moveToPreviousFilled(int pos)
decrement pos until it points to a non 0 or is -1- Parameters:
pos
- -- Returns:
- updated pos
-
iterator
public java.util.Iterator<T> iterator()
- Specified by:
iterator
in interfaceCopyOnWriteIndexPart<T extends FeatureStructure>
- Returns:
- iterator over all the elements
-
moveTo
public int moveTo(FeatureStructure fs)
if the fs is in the set, the iterator should return it. if not, return -1 (makes iterator invalid)- Parameters:
fs
- position to this fs- Returns:
- the index if present, otherwise -1;
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getCapacity
public int getCapacity()
- Returns:
- the capacity >= size
- See Also:
Common_hash_support.getCapacity()
-
size
public final int size()
- Specified by:
size
in interfaceCopyOnWriteIndexPart<T extends FeatureStructure>
- Returns:
- the size
- See Also:
Common_hash_support.size()
-
isOriginal
public boolean isOriginal()
- Specified by:
isOriginal
in interfaceCopyOnWriteIndexPart<T extends FeatureStructure>
- Returns:
- true if this cow version is the same as the original. true means the index has not been updated
-
copyToArray
public int copyToArray(T[] target, int startingIndexInTarget)
Description copied from interface:CopyOnWriteIndexPart
Copy FS refs to target from this index part- Specified by:
copyToArray
in interfaceCopyOnWriteIndexPart<T extends FeatureStructure>
- Parameters:
target
- the target array to copy intostartingIndexInTarget
- the starting index in the target array- Returns:
- startingIndexInTarget + size
-
-