Package org.apache.uima.internal.util
Class Obj2IntIdentityHashMap<T>
java.lang.Object
org.apache.uima.internal.util.Common_hash_support
org.apache.uima.internal.util.Obj2IntIdentityHashMap<T>
A Map from non-null Objects of type T to ints int value 0 reserved to mean object is not in the
table.
This impl is for use in a single thread case only, for table updates 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 ClassesModifier and TypeClassDescriptionprivate classNested classes/interfaces inherited from class org.apache.uima.internal.util.Common_hash_support
Common_hash_support.CommonCopyOld2New, Common_hash_support.CommonKeyIterator -
Field Summary
FieldsFields 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
ConstructorsConstructorDescriptionObj2IntIdentityHashMap(int initialCapacity, Class<T> clazz, T removedMarker) Obj2IntIdentityHashMap(Class<T> clazz, T removedMarker) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbooleanprotected voidcopy_to_new_table(int newCapacity, int oldCapacity, Common_hash_support.CommonCopyOld2New commonCopy) intprivate intfindPosition(T obj) returns a position in the key/value table if the key is not found, then the position will be to the place where the key would be put upon adding (without reusing REMOVED, and the current internal value of keys[position] would be 0.intT[]getKeys()protected booleanis_valid_key(int pos) iterator()protected intprotected voidnewKeysAndValues(int capacity) intprivate voidused for increasing table sizeintCan'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.toString()Methods inherited from class org.apache.uima.internal.util.Common_hash_support
clear, commonPutOrAddNotFound, commonRemove, debugValidate, findPosition, getCapacity, incrementSize, moveToNextFilled, moveToPreviousFilled, newTable, resetHistogram, showHistogram, size, tableSpace
-
Field Details
-
removedMarker
-
componentType
-
keys
-
values
private int[] values
-
-
Constructor Details
-
Obj2IntIdentityHashMap
-
Obj2IntIdentityHashMap
- 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
-
-
Method Details
-
findPosition
returns a position in the key/value table if the key is not found, then the position will be to the place where the key would be put upon adding (without reusing REMOVED, and the current internal value of keys[position] would be 0. if the key is found, then keys[position] == key- Parameters:
obj- the object to find- Returns:
- the probeAddr in keys array - might reference a slot holding null, or the key value if found
-
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
-
get
-
put
- Parameters:
obj- the keyvalue- the value- Returns:
- the previous value, or 0 if this map did not already contain the specified key
-
putInner
used for increasing table size- Parameters:
rawKey-
-
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- Parameters:
rawKey- the value to remove- Returns:
- the value previously associated with the key, or 0 if none
-
getKeys
-
iterator
-
toString
-
is_valid_key
protected boolean is_valid_key(int pos) - Specified by:
is_valid_keyin classCommon_hash_support
-
keys_length
protected int keys_length()- Specified by:
keys_lengthin classCommon_hash_support
-
newKeysAndValues
protected void newKeysAndValues(int capacity) - Specified by:
newKeysAndValuesin classCommon_hash_support
-
clearKeysAndValues
protected void clearKeysAndValues()- Specified by:
clearKeysAndValuesin classCommon_hash_support
-
copy_to_new_table
protected void copy_to_new_table(int newCapacity, int oldCapacity, Common_hash_support.CommonCopyOld2New commonCopy) - Specified by:
copy_to_new_tablein classCommon_hash_support
-