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
- All Implemented Interfaces:
java.lang.Iterable<IntEntry<E>>
public class Int2ObjHashMap<T,E extends T> extends Common_hash_support implements java.lang.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 Modifier and Type Class Description private class
Int2ObjHashMap.KeyIterator
-
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 Modifier and Type Field Description private java.lang.Class<T>
componentType
private int[]
keys
private static int
REMOVED_KEY
private T[]
values
-
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
Constructors Modifier Constructor Description Int2ObjHashMap(java.lang.Class<T> clazz)
Int2ObjHashMap(java.lang.Class<T> clazz, int initialSizeBeforeExpanding)
private
Int2ObjHashMap(Int2ObjHashMap orig)
for use by copy
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
clearKeysAndValues()
T
computeIfAbsent(int key, java.util.function.IntFunction<T> mappingFunction)
boolean
containsKey(int key)
Int2ObjHashMap<T,E>
copy()
protected void
copy_to_new_table(int newCapacity, int oldCapacity, Common_hash_support.CommonCopyOld2New commonCopy)
private int
findPosition(int key)
Searches the keys for a matchE
get(int key)
int[]
getSortedKeys()
protected boolean
is_valid_key(int pos)
java.util.Iterator<IntEntry<E>>
iterator()
IntListIterator
keyIterator()
IntListIterator
keyIterator(int aKey)
protected int
keys_length()
IntKeyValueIterator
keyValueIterator(int aKey)
protected void
newKeysAndValues(int size)
T
put(int key, T value)
T
putIfAbsent(int key, T value)
void
putInner(int key, T value)
E
remove(int key)
java.util.Iterator<E>
values()
T[]
valuesArray()
-
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 Detail
-
REMOVED_KEY
private static final int REMOVED_KEY
- See Also:
- Constant Field Values
-
keys
private int[] keys
-
values
private T[] values
-
componentType
private final java.lang.Class<T> componentType
-
-
Constructor Detail
-
Int2ObjHashMap
public Int2ObjHashMap(java.lang.Class<T> clazz)
-
Int2ObjHashMap
public Int2ObjHashMap(java.lang.Class<T> clazz, int initialSizeBeforeExpanding)
-
Int2ObjHashMap
private Int2ObjHashMap(Int2ObjHashMap orig)
for use by copy- Parameters:
clazz
-initialCapacity
-
-
-
Method Detail
-
findPosition
private int findPosition(int key)
Searches the keys for a match- Parameters:
key
- -- Returns:
- the probeAddr in keys array - The value[probeAddr] is 0 value if not found
-
get
public E get(int key)
-
remove
public E remove(int key)
-
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)
-
computeIfAbsent
public T computeIfAbsent(int key, java.util.function.IntFunction<T> mappingFunction)
-
putInner
public void putInner(int key, T value)
-
getSortedKeys
public int[] getSortedKeys()
-
keyIterator
public IntListIterator keyIterator()
-
keyIterator
public IntListIterator keyIterator(int aKey)
-
keyValueIterator
public IntKeyValueIterator keyValueIterator(int aKey)
-
values
public java.util.Iterator<E> values()
- Returns:
- an iterator<T> over the values in random order
-
valuesArray
public T[] valuesArray()
-
copy
public Int2ObjHashMap<T,E> copy()
-
iterator
public java.util.Iterator<IntEntry<E>> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<T>
-
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
-
-