Package org.hipparchus.util
Class AbstractOpenIntHashMap
- java.lang.Object
-
- org.hipparchus.util.AbstractOpenIntHashMap
-
- Direct Known Subclasses:
OpenIntToDoubleHashMap,OpenIntToFieldHashMap
public abstract class AbstractOpenIntHashMap extends Object
Base class for open addressed map from int.- Since:
- 3.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAbstractOpenIntHashMap.BaseIteratorIterator class for the map.protected static classAbstractOpenIntHashMap.InsertionHolderHolder for handling values insertion.protected static interfaceAbstractOpenIntHashMap.ValueCopierInterface for copying values.
-
Field Summary
Fields Modifier and Type Field Description protected static intDEFAULT_EXPECTED_SIZEDefault starting size.protected static intRESIZE_MULTIPLIERMultiplier for size growth when map fills up.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractOpenIntHashMap()Build an empty map with default size.protectedAbstractOpenIntHashMap(int expectedSize)Build an empty map with specified size.protectedAbstractOpenIntHashMap(AbstractOpenIntHashMap source)Copy constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancontainsKey(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 booleanequalStates(AbstractOpenIntHashMap other)Check if states are equals.protected intgetCapacity()Get capacity.intgetSize()Get the number of elements stored in the map.protected abstract intgrowTable(int oldIndex)Grow the tables.protected intkeysStatesHashCode()Compute 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 voidresetCount()Reset count.intsize()Get the number of elements stored in the map.
-
-
-
Field Detail
-
DEFAULT_EXPECTED_SIZE
protected static final int DEFAULT_EXPECTED_SIZE
Default starting size.This must be a power of two for bit mask to work properly.
- See Also:
- Constant Field Values
-
RESIZE_MULTIPLIER
protected static final int RESIZE_MULTIPLIER
Multiplier for size growth when map fills up.This must be a power of two for bit mask to work properly.
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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
protected AbstractOpenIntHashMap(AbstractOpenIntHashMap source)
Copy constructor.- Parameters:
source- map to copy
-
-
Method Detail
-
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
protected AbstractOpenIntHashMap.InsertionHolder put(int key)
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
protected int doGrowTable(int oldIndex, AbstractOpenIntHashMap.ValueCopier valueCopier)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
protected boolean equalKeys(AbstractOpenIntHashMap other)
Check if keys are equals.- Parameters:
other- other map- Returns:
- true if keys are equals
-
equalStates
protected boolean equalStates(AbstractOpenIntHashMap other)
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
-
-