Package org.hipparchus.util
Class AbstractOpenIntHashMap
java.lang.Object
org.hipparchus.util.AbstractOpenIntHashMap
- Direct Known Subclasses:
OpenIntToDoubleHashMap,OpenIntToFieldHashMap
Base class for open addressed map from int.
- Since:
- 3.1
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classIterator class for the map.protected static classHolder for handling values insertion.protected static interfaceInterface for copying values. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intDefault starting size.protected static final intMultiplier for size growth when map fills up. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBuild an empty map with default size.protectedAbstractOpenIntHashMap(int expectedSize) Build an empty map with specified size.protectedCopy constructor. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(int key) Check if a value is associated with a key.booleancontainsKey(int key, int index) Check if the tables contain an element associated with specified key at specified index.protected intdoGrowTable(int oldIndex, AbstractOpenIntHashMap.ValueCopier valueCopier) Grow the tables.protected voiddoRemove(int index) Remove an element at specified index.protected booleanequalKeys(AbstractOpenIntHashMap other) Check if keys are equals.protected booleanCheck if states are equals.protected intGet capacity.intgetSize()Get the number of elements stored in the map.protected abstract intgrowTable(int oldIndex) Grow the tables.protected intCompute partial hashcode on keys and states.protected intlocate(int key) Locate the index of value associated with the given keyprotected AbstractOpenIntHashMap.InsertionHolderput(int key) Put a value associated with a key in the map.protected final voidReset count.intsize()Get the number of elements stored in the map.
-
Field Details
-
DEFAULT_EXPECTED_SIZE
protected static final int DEFAULT_EXPECTED_SIZEDefault starting size.This must be a power of two for bit mask to work properly.
- See Also:
-
RESIZE_MULTIPLIER
protected static final int RESIZE_MULTIPLIERMultiplier for size growth when map fills up.This must be a power of two for bit mask to work properly.
- See Also:
-
-
Constructor Details
-
AbstractOpenIntHashMap
protected AbstractOpenIntHashMap()Build an empty map with default size. -
AbstractOpenIntHashMap
protected AbstractOpenIntHashMap(int expectedSize) Build an empty map with specified size.- Parameters:
expectedSize- expected number of elements in the map
-
AbstractOpenIntHashMap
Copy constructor.- Parameters:
source- map to copy
-
-
Method Details
-
getCapacity
protected int getCapacity()Get capacity.- Returns:
- capacity
- Since:
- 3.1
-
getSize
public int getSize()Get the number of elements stored in the map.- Returns:
- number of elements stored in the map
-
resetCount
protected final void resetCount()Reset count.- Since:
- 3.1
-
containsKey
public boolean containsKey(int key) Check if a value is associated with a key.- Parameters:
key- key to check- Returns:
- true if a value is associated with key
-
size
public int size()Get the number of elements stored in the map.- Returns:
- number of elements stored in the map
-
containsKey
public boolean containsKey(int key, int index) Check if the tables contain an element associated with specified key at specified index.- Parameters:
key- key to checkindex- index to check- Returns:
- true if an element is associated with key at index
-
locate
protected int locate(int key) Locate the index of value associated with the given key- Parameters:
key- key associated with the data- Returns:
- index of value associated with the given key or negative if key not present
-
doRemove
protected void doRemove(int index) Remove an element at specified index.- Parameters:
index- index of the element to remove
-
put
Put a value associated with a key in the map.- Parameters:
key- key to which value is associated- Returns:
- holder to manage insertion
-
growTable
protected abstract int growTable(int oldIndex) Grow the tables.- Parameters:
oldIndex- index the entry being inserted should have used- Returns:
- index the entry being inserted should really use
-
doGrowTable
Grow the tables.- Parameters:
oldIndex- index the entry being inserted should have usedvalueCopier- copier for existing values- Returns:
- index the entry being inserted should really use
-
equalKeys
Check if keys are equals.- Parameters:
other- other map- Returns:
- true if keys are equals
-
equalStates
Check if states are equals.- Parameters:
other- other map- Returns:
- true if states are equals
-
keysStatesHashCode
protected int keysStatesHashCode()Compute partial hashcode on keys and states.- Returns:
- partial hashcode on keys and states
-