Package org.apache.uima.internal.util
Class Int2ObjHashMap<T,E extends T>
java.lang.Object
org.apache.uima.internal.util.Common_hash_support
org.apache.uima.internal.util.Int2ObjHashMap<T,E>
- Type Parameters:
T
- the type of the component type, must match the clazz in the constructor callE
- the type of the elements
public class Int2ObjHashMap<T,E extends T>
extends Common_hash_support
implements Iterable<IntEntry<E>>
A map<int, T>
based on JCasHashMap, but without the multi-threading support
This impl is for use in a single thread case only
Supports shrinking (reallocating the big table)
Implements Map - like interface: keys are non-0 ints - 0 is reserved for the empty key slot -
Integer.MIN_VALUE is reserved for removed slot
values can be anything, but null is the value returned by get if not found so values probably
should not be null
remove supported by replacing the value slot with null, and replacing the key slot with a
"removed" token. A cleanout of removed items occurs when necessary.
-
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
ConstructorDescriptionInt2ObjHashMap
(Class<T> clazz) Int2ObjHashMap
(Class<T> clazz, int initialSizeBeforeExpanding) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
computeIfAbsent
(int key, IntFunction<T> mappingFunction) boolean
containsKey
(int key) copy()
protected void
copy_to_new_table
(int newCapacity, int oldCapacity, Common_hash_support.CommonCopyOld2New commonCopy) get
(int key) int[]
protected boolean
is_valid_key
(int pos) iterator()
keyIterator
(int aKey) protected int
keyValueIterator
(int aKey) protected void
newKeysAndValues
(int size) putIfAbsent
(int key, T value) void
remove
(int key) values()
T[]
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, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Int2ObjHashMap
-
Int2ObjHashMap
-
-
Method Details
-
get
-
remove
-
copy_to_new_table
protected void copy_to_new_table(int newCapacity, int oldCapacity, Common_hash_support.CommonCopyOld2New commonCopy) - Specified by:
copy_to_new_table
in classCommon_hash_support
-
containsKey
public boolean containsKey(int key) -
put
-
computeIfAbsent
-
putIfAbsent
-
putInner
-
getSortedKeys
public int[] getSortedKeys() -
keyIterator
-
keyIterator
-
keyValueIterator
-
values
- Returns:
- an iterator<T> over the values in random order
-
valuesArray
-
copy
-
iterator
-
keys_length
protected int keys_length()- Specified by:
keys_length
in classCommon_hash_support
-
is_valid_key
protected boolean is_valid_key(int pos) - Specified by:
is_valid_key
in classCommon_hash_support
-
newKeysAndValues
protected void newKeysAndValues(int size) - Specified by:
newKeysAndValues
in classCommon_hash_support
-
clearKeysAndValues
protected void clearKeysAndValues()- Specified by:
clearKeysAndValues
in classCommon_hash_support
-