Class Long2LongOpenBigHashMap
- All Implemented Interfaces:
it.unimi.dsi.fastutil.Function<Long,,Long> it.unimi.dsi.fastutil.Hash,it.unimi.dsi.fastutil.longs.Long2LongFunction,it.unimi.dsi.fastutil.longs.Long2LongMap,Serializable,Function<Long,,Long> LongUnaryOperator,Map<Long,Long>
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class it.unimi.dsi.fastutil.longs.AbstractLong2LongMap
it.unimi.dsi.fastutil.longs.AbstractLong2LongMap.BasicEntry, it.unimi.dsi.fastutil.longs.AbstractLong2LongMap.BasicEntrySetNested classes/interfaces inherited from interface it.unimi.dsi.fastutil.Hash
it.unimi.dsi.fastutil.Hash.Strategy<K>Nested classes/interfaces inherited from interface it.unimi.dsi.fastutil.longs.Long2LongMap
it.unimi.dsi.fastutil.longs.Long2LongMap.Entry, it.unimi.dsi.fastutil.longs.Long2LongMap.FastEntrySet -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether this map contains the key zero.protected it.unimi.dsi.fastutil.longs.Long2LongMap.FastEntrySetCached set of entries.protected final floatThe acceptable load factor.protected LongBigArrayThe array of keys.protected it.unimi.dsi.fastutil.longs.LongSetCached set of keys.protected 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 longNumber of entries in the set (including the key zero, if present).protected LongBigArrayThe array of values.protected it.unimi.dsi.fastutil.longs.LongCollectionCached collection of values.Fields inherited from class it.unimi.dsi.fastutil.longs.AbstractLong2LongFunction
defRetValueFields 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
ConstructorsConstructorDescriptionCreates a new hash map with initial expectedBigArrays.SEGMENT_SIZEentries andHash.DEFAULT_LOAD_FACTORas load factor.Long2LongOpenBigHashMap(long expected) Creates a new hash map withHash.DEFAULT_LOAD_FACTORas load factor.Long2LongOpenBigHashMap(long expected, float f) Creates a new hash map.Long2LongOpenBigHashMap(it.unimi.dsi.fastutil.longs.Long2LongMap m) Creates a new hash map withHash.DEFAULT_LOAD_FACTORas load factor copying a given type-specific one.Long2LongOpenBigHashMap(it.unimi.dsi.fastutil.longs.Long2LongMap m, float f) Creates a new hash map copying a given type-specific one.Long2LongOpenBigHashMap(Map<? extends Long, ? extends Long> m) Creates a new hash map withHash.DEFAULT_LOAD_FACTORas load factor copying a given one.Long2LongOpenBigHashMap(Map<? extends Long, ? extends Long> m, float f) Creates a new hash map copying a given one. -
Method Summary
Modifier and TypeMethodDescriptionlongaddTo(long k, long incr) Adds an increment to value currently associated with a key.voidclear()longcompute(long k, BiFunction<? super Long, ? super Long, ? extends Long> remappingFunction) longcomputeIfAbsent(long k, LongUnaryOperator mappingFunction) longcomputeIfAbsentNullable(long k, LongFunction<? extends Long> mappingFunction) longcomputeIfPresent(long k, BiFunction<? super Long, ? super Long, ? extends Long> remappingFunction) booleancontainsKey(long k) booleancontainsValue(long v) longget(long k) longgetOrDefault(long k, long defaultValue) booleanisEmpty()it.unimi.dsi.fastutil.longs.LongSetkeySet()it.unimi.dsi.fastutil.longs.Long2LongMap.FastEntrySetlongmerge(long k, long v, BiFunction<? super Long, ? super Long, ? extends Long> remappingFunction) longput(long k, long v) voidlongputIfAbsent(long k, long v) protected voidrehash(long newN) Rehashes the map.longremove(long k) booleanremove(long k, long v) longreplace(long k, long v) booleanreplace(long k, 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.intsize()longsizeOf()Returns the size of this hash map in bytes.booleantrim()Rehashes the map, making the table as small as possible.booleantrim(long n) Rehashes this map if the table is too large.it.unimi.dsi.fastutil.longs.LongCollectionvalues()Methods inherited from class it.unimi.dsi.fastutil.longs.AbstractLong2LongMap
equals, hashCode, mergeLong, toStringMethods inherited from class it.unimi.dsi.fastutil.longs.AbstractLong2LongFunction
defaultReturnValue, defaultReturnValueMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface it.unimi.dsi.fastutil.Function
applyMethods inherited from interface it.unimi.dsi.fastutil.longs.Long2LongFunction
andThen, andThenByte, andThenChar, andThenDouble, andThenFloat, andThenInt, andThenLong, andThenObject, andThenReference, andThenShort, applyAsLong, compose, composeByte, composeChar, composeDouble, composeFloat, composeInt, composeLong, composeObject, composeReference, composeShortMethods inherited from interface it.unimi.dsi.fastutil.longs.Long2LongMap
compute, computeIfAbsent, computeIfAbsent, computeIfAbsentPartial, computeIfPresent, containsKey, containsValue, defaultReturnValue, defaultReturnValue, entrySet, forEach, get, getOrDefault, merge, mergeLong, put, putIfAbsent, remove, remove, replace, replaceMethods inherited from interface java.util.function.LongUnaryOperator
andThen, composeMethods inherited from interface java.util.Map
replaceAll
-
Field Details
-
key
The array of keys. -
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. -
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. -
entries
protected it.unimi.dsi.fastutil.longs.Long2LongMap.FastEntrySet entriesCached set of entries. -
keys
protected it.unimi.dsi.fastutil.longs.LongSet keysCached set of keys. -
values
protected it.unimi.dsi.fastutil.longs.LongCollection valuesCached collection of values.
-
-
Constructor Details
-
Long2LongOpenBigHashMap
public Long2LongOpenBigHashMap(long expected, float f) 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.
-
Long2LongOpenBigHashMap
public Long2LongOpenBigHashMap(long expected) Creates a new hash map withHash.DEFAULT_LOAD_FACTORas load factor.- Parameters:
expected- the expected number of elements in the hash map.
-
Long2LongOpenBigHashMap
public Long2LongOpenBigHashMap()Creates a new hash map with initial expectedBigArrays.SEGMENT_SIZEentries andHash.DEFAULT_LOAD_FACTORas load factor. -
Long2LongOpenBigHashMap
Creates a new hash map copying a given one.- Parameters:
m- aMapto be copied into the new hash map.f- the load factor.
-
Long2LongOpenBigHashMap
Creates a new hash map withHash.DEFAULT_LOAD_FACTORas load factor copying a given one.- Parameters:
m- aMapto be copied into the new hash map.
-
Long2LongOpenBigHashMap
public Long2LongOpenBigHashMap(it.unimi.dsi.fastutil.longs.Long2LongMap m, float f) Creates a new hash map copying a given type-specific one.- Parameters:
m- a type-specific map to be copied into the new hash map.f- the load factor.
-
Long2LongOpenBigHashMap
public Long2LongOpenBigHashMap(it.unimi.dsi.fastutil.longs.Long2LongMap m) Creates a new hash map withHash.DEFAULT_LOAD_FACTORas load factor copying a given type-specific one.- Parameters:
m- a type-specific map to be copied into the new hash map.
-
-
Method Details
-
sizeOf
public long sizeOf()Returns the size of this hash map in bytes. -
putAll
-
put
public long put(long k, long v) - Specified by:
putin interfaceit.unimi.dsi.fastutil.longs.Long2LongFunction
-
addTo
public long addTo(long k, 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:
k- the 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 k) - Specified by:
removein interfaceit.unimi.dsi.fastutil.longs.Long2LongFunction
-
get
public long get(long k) - Specified by:
getin interfaceit.unimi.dsi.fastutil.longs.Long2LongFunction
-
containsKey
public boolean containsKey(long k) - Specified by:
containsKeyin interfaceit.unimi.dsi.fastutil.longs.Long2LongFunction- Specified by:
containsKeyin interfaceit.unimi.dsi.fastutil.longs.Long2LongMap- Overrides:
containsKeyin classit.unimi.dsi.fastutil.longs.AbstractLong2LongMap
-
containsValue
public boolean containsValue(long v) - Specified by:
containsValuein interfaceit.unimi.dsi.fastutil.longs.Long2LongMap- Overrides:
containsValuein classit.unimi.dsi.fastutil.longs.AbstractLong2LongMap
-
getOrDefault
public long getOrDefault(long k, long defaultValue) - Specified by:
getOrDefaultin interfaceit.unimi.dsi.fastutil.longs.Long2LongFunction- Specified by:
getOrDefaultin interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
-
putIfAbsent
public long putIfAbsent(long k, long v) - Specified by:
putIfAbsentin interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
-
remove
public boolean remove(long k, long v) - Specified by:
removein interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
-
replace
public boolean replace(long k, long oldValue, long v) - Specified by:
replacein interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
-
replace
public long replace(long k, long v) - Specified by:
replacein interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
-
computeIfAbsent
- Specified by:
computeIfAbsentin interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
-
computeIfAbsentNullable
- Specified by:
computeIfAbsentNullablein interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
-
computeIfPresent
public long computeIfPresent(long k, BiFunction<? super Long, ? super Long, ? extends Long> remappingFunction) - Specified by:
computeIfPresentin interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
-
compute
- Specified by:
computein interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
-
merge
public long merge(long k, long v, BiFunction<? super Long, ? super Long, ? extends Long> remappingFunction) - Specified by:
mergein interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
-
clear
public void clear() -
size
public int size() -
isEmpty
public boolean isEmpty() -
long2LongEntrySet
public it.unimi.dsi.fastutil.longs.Long2LongMap.FastEntrySet long2LongEntrySet()- Specified by:
long2LongEntrySetin interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
-
keySet
public it.unimi.dsi.fastutil.longs.LongSet keySet() -
values
public it.unimi.dsi.fastutil.longs.LongCollection values() -
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
-