Package org.apache.uima.internal.util
Class Int2IntHashMap
java.lang.Object
org.apache.uima.internal.util.Int2IntHashMap
A map<int, int>
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 and values are ints
Entry set not (yet) impl
keys must be non-0; 0 is reserved to be an empty slot
values can be anything, but 0 is the value returned by get if not found so
values probably should not be 0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class
private class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int[]
private int[]
private final int
private int[]
private final float
private int
private boolean
private int
private int
private static final boolean
private int[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
boolean
containsKey
(int key) private int
find
(int key) It gets a ref to the current value of table, and then searches that int array.private int
find2
(int[] localKeys, int key, int probeAddr) int
get
(int key) int[]
private void
private void
boolean
isKeyValid
(int position) keyIterator
(int aKey) keyValueIterator
(int aKey) private int
moveToNextFilled
(int pos) advance pos until it points to a non 0 or is 1 past endprivate int
moveToPreviousFilled
(int pos) decrement pos until it points to a non 0 or is -1private void
newTable
(int capacity) private void
newTableKeepSize
(int capacity) (package private) static int
nextHigherPowerOf2
(int i) int
put
(int key, int value) void
putInner
(int key, int value) private void
void
int
size()
private void
updateHistogram
(int nbrProbes)
-
Field Details
-
TUNE
private static final boolean TUNE- See Also:
-
EMPTY_INT_ARRAY
private static final int[] EMPTY_INT_ARRAY -
loadFactor
private final float loadFactor- See Also:
-
initialCapacity
private final int initialCapacity -
histogram
private int[] histogram -
maxProbe
private int maxProbe -
sizeWhichTriggersExpansion
private int sizeWhichTriggersExpansion -
size
private int size -
keys
private int[] keys -
values
private int[] values -
secondTimeShrinkable
private boolean secondTimeShrinkable
-
-
Constructor Details
-
Int2IntHashMap
public Int2IntHashMap() -
Int2IntHashMap
public Int2IntHashMap(int initialCapacity)
-
-
Method Details
-
nextHigherPowerOf2
static int nextHigherPowerOf2(int i) -
newTableKeepSize
private void newTableKeepSize(int capacity) -
incrementSize
private void incrementSize() -
increaseTableCapacity
private void increaseTableCapacity() -
newTable
private void newTable(int capacity) -
resetHistogram
private void resetHistogram() -
clear
public void clear() -
find
private int find(int key) It gets a ref to the current value of table, and then searches that int array.- Parameters:
key
- -- Returns:
- the probeAddr in keys array - might have a 0 value, or the key value if found
-
find2
private int find2(int[] localKeys, int key, int probeAddr) -
updateHistogram
private void updateHistogram(int nbrProbes) -
get
public int get(int key) -
containsKey
public boolean containsKey(int key) -
isKeyValid
public boolean isKeyValid(int position) -
put
public int put(int key, int value) -
putInner
public void putInner(int key, int value) -
size
public int size() -
moveToNextFilled
private int moveToNextFilled(int pos) advance pos until it points to a non 0 or is 1 past end- Parameters:
pos
-- Returns:
- updated pos
-
moveToPreviousFilled
private int moveToPreviousFilled(int pos) decrement pos until it points to a non 0 or is -1- Parameters:
pos
-- Returns:
- updated pos
-
getSortedKeys
public int[] getSortedKeys() -
keyIterator
-
keyIterator
-
keyValueIterator
-
keyValueIterator
-
showHistogram
public void showHistogram()
-