Class LongLong2LongOpenCustomBigHashMap
- All Implemented Interfaces:
it.unimi.dsi.fastutil.Hash
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface it.unimi.dsi.fastutil.Hash
it.unimi.dsi.fastutil.Hash.Strategy<K> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether this map contains the key zero.protected longThe default return value forget(),put()andremove().protected final floatThe acceptable load factor.protected LongBigArrayThe array of keys.protected LongBigArrayprotected longThe mask for wrapping a position counter.protected longThreshold after which we rehash.protected final longWe never resize below this threshold, which is the construction-time {#n}.protected longThe current table size.protected final longThe two-part value denoting unmapped keys (or null keys).protected final longprotected longNumber of entries in the set (including the key zero, if present).protected final LongLong2LongOpenCustomBigHashMap.HashStrategyThe hash strategy of this custom map.protected LongBigArrayThe array of values.Fields inherited from interface it.unimi.dsi.fastutil.Hash
DEFAULT_GROWTH_FACTOR, DEFAULT_INITIAL_SIZE, DEFAULT_LOAD_FACTOR, FAST_LOAD_FACTOR, FREE, OCCUPIED, PRIMES, REMOVED, VERY_FAST_LOAD_FACTOR -
Constructor Summary
ConstructorsConstructorDescriptionLongLong2LongOpenCustomBigHashMap(long expected, float f, LongLong2LongOpenCustomBigHashMap.HashStrategy strategy) Creates a new hash map and zero based null keys.LongLong2LongOpenCustomBigHashMap(long expected, float f, LongLong2LongOpenCustomBigHashMap.HashStrategy strategy, long nullKey1, long nullKey2) Creates a new hash map.LongLong2LongOpenCustomBigHashMap(long expected, LongLong2LongOpenCustomBigHashMap.HashStrategy strategy) Creates a new hash map withHash.DEFAULT_LOAD_FACTORas load factor and zero based null keys.LongLong2LongOpenCustomBigHashMap(long expected, LongLong2LongOpenCustomBigHashMap.HashStrategy strategy, long nullKey1, long nullKey2) Creates a new hash map withHash.DEFAULT_LOAD_FACTORas load factor.Creates a new hash map with initial expectedBigArrays.SEGMENT_SIZEentries,Hash.DEFAULT_LOAD_FACTORas load factor, and zero based null keys.LongLong2LongOpenCustomBigHashMap(LongLong2LongOpenCustomBigHashMap.HashStrategy strategy, long nullKey1, long nullKey2) Creates a new hash map with initial expectedBigArrays.SEGMENT_SIZEentries andHash.DEFAULT_LOAD_FACTORas load factor. -
Method Summary
Modifier and TypeMethodDescriptionlongaddTo(long k1, long k2, long incr) Adds an increment to value currently associated with a key.voidclear()Removes all elements from this map.longcomputeIfAbsent(long k1, long k2, LongBinaryOperator mappingFunction) booleancontainsKey(long k1, long k2) booleancontainsValue(long v) longvoiddefaultReturnValue(long rv) longget(long k1, long k2) longgetOrDefault(long k1, long k2, long defaultValue) booleanisEmpty()longmerge(long k1, long k2, long v, BiFunction<? super Long, ? super Long, ? extends Long> remappingFunction) longput(long k1, long k2, long v) longputIfAbsent(long k1, long k2, long v) protected voidrehash(long newN) Rehashes the map.longremove(long k1, long k2) booleanremove(long k1, long k2, long v) longreplace(long k1, long k2, long v) booleanreplace(long k1, long k2, long oldValue, long v) protected final voidshiftKeys(long pos) Shifts left entries with the specified hash code, starting at the specified position, and empties the resulting free entry.longsize()longsizeOf()Returns the size of this hash map in bytes.strategy()Returns the hashing strategy.booleantrim()Rehashes the map, making the table as small as possible.booleantrim(long n) Rehashes this map if the table is too large.
-
Field Details
-
key1
The array of keys. -
key2
-
value
The array of values. -
mask
protected long maskThe mask for wrapping a position counter. -
containsNullKey
protected boolean containsNullKeyWhether this map contains the key zero. -
strategy
The hash strategy of this custom map. -
n
protected long nThe current table size. -
maxFill
protected long maxFillThreshold after which we rehash. It must be the table size timesf. -
minN
protected final long minNWe never resize below this threshold, which is the construction-time {#n}. -
size
protected long sizeNumber of entries in the set (including the key zero, if present). -
f
protected final float fThe acceptable load factor. -
defRetValue
protected long defRetValueThe default return value forget(),put()andremove(). -
nullKey1
protected final long nullKey1The two-part value denoting unmapped keys (or null keys). These values may be passed back via the HashStrategy callback during equality checks, even though no keys with these values have been added. -
nullKey2
protected final long nullKey2
-
-
Constructor Details
-
LongLong2LongOpenCustomBigHashMap
public LongLong2LongOpenCustomBigHashMap(long expected, float f, LongLong2LongOpenCustomBigHashMap.HashStrategy strategy, long nullKey1, long nullKey2) Creates a new hash map.The actual table size will be the least power of two greater than
expected/f.- Parameters:
expected- the expected number of elements in the hash map.f- the load factor.strategy- the strategy.nullKey1- first half of the representation for unmapped keys.nullKey2- second half of the representation for unmapped keys.
-
LongLong2LongOpenCustomBigHashMap
public LongLong2LongOpenCustomBigHashMap(long expected, LongLong2LongOpenCustomBigHashMap.HashStrategy strategy, long nullKey1, long nullKey2) Creates a new hash map withHash.DEFAULT_LOAD_FACTORas load factor.- Parameters:
expected- the expected number of elements in the hash map.strategy- the strategy.
-
LongLong2LongOpenCustomBigHashMap
public LongLong2LongOpenCustomBigHashMap(long expected, float f, LongLong2LongOpenCustomBigHashMap.HashStrategy strategy) Creates a new hash map and zero based null keys.The actual table size will be the least power of two greater than
expected/f.- Parameters:
expected- the expected number of elements in the hash map.f- the load factor.strategy- the strategy.
-
LongLong2LongOpenCustomBigHashMap
public LongLong2LongOpenCustomBigHashMap(long expected, LongLong2LongOpenCustomBigHashMap.HashStrategy strategy) Creates a new hash map withHash.DEFAULT_LOAD_FACTORas load factor and zero based null keys.- Parameters:
expected- the expected number of elements in the hash map.strategy- the strategy.
-
LongLong2LongOpenCustomBigHashMap
public LongLong2LongOpenCustomBigHashMap(LongLong2LongOpenCustomBigHashMap.HashStrategy strategy, long nullKey1, long nullKey2) Creates a new hash map with initial expectedBigArrays.SEGMENT_SIZEentries andHash.DEFAULT_LOAD_FACTORas load factor.- Parameters:
strategy- the strategy.nullKey1- first half of the representation for unmapped keys.nullKey2- second half of the representation for unmapped keys.
-
LongLong2LongOpenCustomBigHashMap
Creates a new hash map with initial expectedBigArrays.SEGMENT_SIZEentries,Hash.DEFAULT_LOAD_FACTORas load factor, and zero based null keys.- Parameters:
strategy- the strategy.
-
-
Method Details
-
defaultReturnValue
public void defaultReturnValue(long rv) -
defaultReturnValue
public long defaultReturnValue() -
sizeOf
public long sizeOf()Returns the size of this hash map in bytes. -
strategy
Returns the hashing strategy.- Returns:
- the hashing strategy of this custom hash map.
-
put
public long put(long k1, long k2, long v) -
addTo
public long addTo(long k1, long k2, long incr) Adds an increment to value currently associated with a key.Note that this method respects the default return value semantics: when called with a key that does not currently appears in the map, the key will be associated with the default return value plus the given increment.
- Parameters:
k1- the first half of key.k2- the second half of key.incr- the increment.- Returns:
- the old value, or the default return value if no value was present for the given key.
-
shiftKeys
protected final void shiftKeys(long pos) Shifts left entries with the specified hash code, starting at the specified position, and empties the resulting free entry.- Parameters:
pos- a starting position.
-
remove
public long remove(long k1, long k2) -
get
public long get(long k1, long k2) -
containsKey
public boolean containsKey(long k1, long k2) -
containsValue
public boolean containsValue(long v) -
getOrDefault
public long getOrDefault(long k1, long k2, long defaultValue) -
putIfAbsent
public long putIfAbsent(long k1, long k2, long v) -
remove
public boolean remove(long k1, long k2, long v) -
replace
public boolean replace(long k1, long k2, long oldValue, long v) -
replace
public long replace(long k1, long k2, long v) -
computeIfAbsent
-
merge
public long merge(long k1, long k2, long v, BiFunction<? super Long, ? super Long, ? extends Long> remappingFunction) -
clear
public void clear()Removes all elements from this map.To increase object reuse, this method does not change the table size. If you want to reduce the table size, you must use
trim(). -
size
public long size() -
isEmpty
public boolean isEmpty() -
trim
public boolean trim()Rehashes the map, making the table as small as possible.This method rehashes the table to the smallest size satisfying the load factor. It can be used when the set will not be changed anymore, so to optimize access speed and size.
If the table size is already the minimum possible, this method does nothing.
- Returns:
- true if there was enough memory to trim the map.
- See Also:
-
trim
public boolean trim(long n) Rehashes this map if the table is too large.Let N be the smallest table size that can hold
max(n,entries, still satisfying the load factor. If the current table size is smaller than or equal to N, this method does nothing. Otherwise, it rehashes this map in a table of size N.size())This method is useful when reusing maps. Clearing a map leaves the table size untouched. If you are reusing a map many times, you can call this method with a typical size to avoid keeping around a very large table just because of a few large transient maps.
- Parameters:
n- the threshold for the trimming.- Returns:
- true if there was enough memory to trim the map.
- See Also:
-
rehash
protected void rehash(long newN) Rehashes the map.This method implements the basic rehashing strategy, and may be overridden by subclasses implementing different rehashing strategies (e.g., disk-based rehashing). However, you should not override this method unless you understand the internal workings of this class.
- Parameters:
newN- the new size
-