Package org.apache.uima.internal.util
Class ObjHashSet<T>
java.lang.Object
org.apache.uima.internal.util.Common_hash_support
org.apache.uima.internal.util.ObjHashSet<T>
- All Implemented Interfaces:
Iterable<T>
,Collection<T>
,Set<T>
A set of Objects of type T
This impl is for use in a single thread case only, when table is being updated. Multiple reader
threads are OK if there's no writing.
Supports shrinking (reallocating the big table)
Removed objects replaced with special marker object in the table so find operations continue to
work (they can't stop upon finding this object).
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.uima.internal.util.Common_hash_support
Common_hash_support.CommonCopyOld2New, Common_hash_support.CommonKeyIterator
-
Field Summary
Fields inherited from class org.apache.uima.internal.util.Common_hash_support
found_removed, histogram, initialCapacity, loadFactor, maxProbe, MIN_CAPACITY, MIN_CAPACITY_SHRINK, MIN_SIZE, removed, secondTimeShrinkable, sizeWhichTriggersExpansion, TUNE
-
Constructor Summary
ConstructorDescriptionObjHashSet
(int initialCapacity, Class<T> clazz, T removedMarker) ObjHashSet
(Class<T> clazz, T removedMarker) ObjHashSet
(ObjHashSet<T> ohs) Copy constructorObjHashSet
(ObjHashSet<T> ohs, boolean readOnly) -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends T> c) protected void
boolean
boolean
containsAll
(Collection<?> c) protected void
copy_to_new_table
(int new_capacity, int old_capacity, Common_hash_support.CommonCopyOld2New commonCopy) int
get
(int index) For iterator useprotected boolean
is_valid_key
(int pos) boolean
isEmpty()
iterator()
protected int
int
if the fs is in the set, the iterator should return it. if not, return -1 (makes iterator invalid)protected void
newKeysAndValues
(int capacity) boolean
Can't replace the item with a null because other keys that were stored in the table which previously collided with the removed item won't be found.boolean
removeAll
(Collection<?> c) boolean
retainAll
(Collection<?> c) T[]
toArray()
<T2> T2[]
toArray
(T2[] a) toString()
Methods inherited from class org.apache.uima.internal.util.Common_hash_support
clear, commonPutOrAddNotFound, commonRemove, debugValidate, findPosition, incrementSize, moveToNextFilled, moveToPreviousFilled, newTable, resetHistogram, showHistogram, size, tableSpace
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Constructor Details
-
ObjHashSet
-
ObjHashSet
- Parameters:
initialCapacity
- - you can add this many before expansionclazz
- - a superclass of the stored itemsremovedMarker
- - a unique value never stored in the table, used to mark removed items
-
ObjHashSet
Copy constructor- Parameters:
ohs
- -
-
ObjHashSet
-
-
Method Details
-
contains
-
find
- 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
-
add
-
remove
Can't replace the item with a null because other keys that were stored in the table which previously collided with the removed item won't be found. UIMA-4204 -
get
For iterator use- Parameters:
index
- - a magic number returned by the internal find- Returns:
- the T at that spot, or null if nothing there
-
iterator
-
moveTo
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;
-
toArray
public <T2> T2[] toArray(T2[] a) -
toArray
-
toString
-
isEmpty
public boolean isEmpty() -
containsAll
- Specified by:
containsAll
in interfaceCollection<T>
- Specified by:
containsAll
in interfaceSet<T>
-
addAll
-
removeAll
-
retainAll
-
is_valid_key
protected boolean is_valid_key(int pos) - Specified by:
is_valid_key
in classCommon_hash_support
-
keys_length
protected int keys_length()- Specified by:
keys_length
in classCommon_hash_support
-
newKeysAndValues
protected void newKeysAndValues(int capacity) - Specified by:
newKeysAndValues
in classCommon_hash_support
-
clearKeysAndValues
protected void clearKeysAndValues()- Specified by:
clearKeysAndValues
in classCommon_hash_support
-
copy_to_new_table
protected void copy_to_new_table(int new_capacity, int old_capacity, Common_hash_support.CommonCopyOld2New commonCopy) - Specified by:
copy_to_new_table
in classCommon_hash_support
-