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
Modifier and TypeClassDescriptionprotected class
Iterator class for the map.protected static class
Holder for handling values insertion.protected static interface
Interface for copying values. -
Field Summary
Modifier and TypeFieldDescriptionprotected static final int
Default starting size.protected static final int
Multiplier for size growth when map fills up. -
Constructor Summary
ModifierConstructorDescriptionprotected
Build an empty map with default size.protected
AbstractOpenIntHashMap
(int expectedSize) Build an empty map with specified size.protected
Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(int key) Check if a value is associated with a key.boolean
containsKey
(int key, int index) Check if the tables contain an element associated with specified key at specified index.protected int
doGrowTable
(int oldIndex, AbstractOpenIntHashMap.ValueCopier valueCopier) Grow the tables.protected void
doRemove
(int index) Remove an element at specified index.protected boolean
equalKeys
(AbstractOpenIntHashMap other) Check if keys are equals.protected boolean
Check if states are equals.protected int
Get capacity.int
getSize()
Get the number of elements stored in the map.protected abstract int
growTable
(int oldIndex) Grow the tables.protected int
Compute partial hashcode on keys and states.protected int
locate
(int key) Locate the index of value associated with the given keyprotected AbstractOpenIntHashMap.InsertionHolder
put
(int key) Put a value associated with a key in the map.protected void
Reset count.int
size()
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 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
-