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 class
AbstractOpenIntHashMap.BaseIterator
Iterator class for the map.protected static class
AbstractOpenIntHashMap.InsertionHolder
Holder for handling values insertion.protected static interface
AbstractOpenIntHashMap.ValueCopier
Interface for copying values.
-
Field Summary
Fields Modifier and Type Field Description protected static int
DEFAULT_EXPECTED_SIZE
Default starting size.protected static int
RESIZE_MULTIPLIER
Multiplier for size growth when map fills up.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractOpenIntHashMap()
Build an empty map with default size.protected
AbstractOpenIntHashMap(int expectedSize)
Build an empty map with specified size.protected
AbstractOpenIntHashMap(AbstractOpenIntHashMap source)
Copy constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
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
equalStates(AbstractOpenIntHashMap other)
Check if states are equals.protected int
getCapacity()
Get capacity.int
getSize()
Get the number of elements stored in the map.protected abstract int
growTable(int oldIndex)
Grow the tables.protected int
keysStatesHashCode()
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
resetCount()
Reset count.int
size()
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
-
-