Class Long2LongOpenBigHashMap
- java.lang.Object
-
- it.unimi.dsi.fastutil.longs.AbstractLong2LongFunction
-
- it.unimi.dsi.fastutil.longs.AbstractLong2LongMap
-
- io.prestosql.util.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>
public class Long2LongOpenBigHashMap extends it.unimi.dsi.fastutil.longs.AbstractLong2LongMap implements it.unimi.dsi.fastutil.Hash
- See Also:
- Serialized Form
-
-
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.BasicEntrySet
-
Nested classes/interfaces inherited from interface it.unimi.dsi.fastutil.Hash
it.unimi.dsi.fastutil.Hash.Strategy<K extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
containsNullKey
Whether this map contains the key zero.protected it.unimi.dsi.fastutil.longs.Long2LongMap.FastEntrySet
entries
Cached set of entries.protected float
f
The acceptable load factor.protected LongBigArray
key
The array of keys.protected it.unimi.dsi.fastutil.longs.LongSet
keys
Cached set of keys.protected long
mask
The mask for wrapping a position counter.protected long
maxFill
Threshold after which we rehash.protected long
minN
We never resize below this threshold, which is the construction-time {#n}.protected long
n
The current table size.protected long
size
Number of entries in the set (including the key zero, if present).protected LongBigArray
value
The array of values.protected it.unimi.dsi.fastutil.longs.LongCollection
values
Cached collection of values.
-
Constructor Summary
Constructors Constructor Description Long2LongOpenBigHashMap()
Creates a new hash map with initial expectedBigArrays.SEGMENT_SIZE
entries andHash.DEFAULT_LOAD_FACTOR
as load factor.Long2LongOpenBigHashMap(long expected)
Creates a new hash map withHash.DEFAULT_LOAD_FACTOR
as 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_FACTOR
as 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_FACTOR
as 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
addTo(long k, long incr)
Adds an increment to value currently associated with a key.void
clear()
long
compute(long k, BiFunction<? super Long,? super Long,? extends Long> remappingFunction)
long
computeIfAbsent(long k, LongUnaryOperator mappingFunction)
long
computeIfAbsentNullable(long k, LongFunction<? extends Long> mappingFunction)
long
computeIfPresent(long k, BiFunction<? super Long,? super Long,? extends Long> remappingFunction)
boolean
containsKey(long k)
boolean
containsValue(long v)
long
get(long k)
long
getOrDefault(long k, long defaultValue)
boolean
isEmpty()
it.unimi.dsi.fastutil.longs.LongSet
keySet()
it.unimi.dsi.fastutil.longs.Long2LongMap.FastEntrySet
long2LongEntrySet()
long
merge(long k, long v, BiFunction<? super Long,? super Long,? extends Long> remappingFunction)
long
put(long k, long v)
void
putAll(Map<? extends Long,? extends Long> m)
long
putIfAbsent(long k, long v)
protected void
rehash(long newN)
Rehashes the map.long
remove(long k)
boolean
remove(long k, long v)
long
replace(long k, long v)
boolean
replace(long k, long oldValue, long v)
protected void
shiftKeys(long pos)
Shifts left entries with the specified hash code, starting at the specified position, and empties the resulting free entry.int
size()
long
sizeOf()
Returns the size of this hash map in bytes.boolean
trim()
Rehashes the map, making the table as small as possible.boolean
trim(long n)
Rehashes this map if the table is too large.it.unimi.dsi.fastutil.longs.LongCollection
values()
-
Methods inherited from class it.unimi.dsi.fastutil.longs.AbstractLong2LongMap
equals, hashCode, toString
-
Methods inherited from class it.unimi.dsi.fastutil.longs.AbstractLong2LongFunction
defaultReturnValue, defaultReturnValue
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface it.unimi.dsi.fastutil.longs.Long2LongMap
compute, computeIfAbsent, computeIfAbsentPartial, computeIfPresent, containsKey, containsValue, defaultReturnValue, defaultReturnValue, entrySet, get, getOrDefault, merge, put, putIfAbsent, remove, remove, replace, replace
-
Methods inherited from interface java.util.function.LongUnaryOperator
andThen, compose
-
Methods inherited from interface java.util.Map
forEach, replaceAll
-
-
-
-
Field Detail
-
key
protected LongBigArray key
The array of keys.
-
value
protected LongBigArray value
The array of values.
-
mask
protected long mask
The mask for wrapping a position counter.
-
containsNullKey
protected boolean containsNullKey
Whether this map contains the key zero.
-
n
protected long n
The current table size.
-
maxFill
protected long maxFill
Threshold after which we rehash. It must be the table size timesf
.
-
minN
protected final long minN
We never resize below this threshold, which is the construction-time {#n}.
-
size
protected long size
Number of entries in the set (including the key zero, if present).
-
f
protected final float f
The acceptable load factor.
-
entries
protected it.unimi.dsi.fastutil.longs.Long2LongMap.FastEntrySet entries
Cached set of entries.
-
keys
protected it.unimi.dsi.fastutil.longs.LongSet keys
Cached set of keys.
-
values
protected it.unimi.dsi.fastutil.longs.LongCollection values
Cached collection of values.
-
-
Constructor Detail
-
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_FACTOR
as 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_SIZE
entries andHash.DEFAULT_LOAD_FACTOR
as load factor.
-
Long2LongOpenBigHashMap
public Long2LongOpenBigHashMap(Map<? extends Long,? extends Long> m, float f)
Creates a new hash map copying a given one.- Parameters:
m
- aMap
to be copied into the new hash map.f
- the load factor.
-
Long2LongOpenBigHashMap
public Long2LongOpenBigHashMap(Map<? extends Long,? extends Long> m)
Creates a new hash map withHash.DEFAULT_LOAD_FACTOR
as load factor copying a given one.- Parameters:
m
- aMap
to 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_FACTOR
as load factor copying a given type-specific one.- Parameters:
m
- a type-specific map to be copied into the new hash map.
-
-
Method Detail
-
sizeOf
public long sizeOf()
Returns the size of this hash map in bytes.
-
put
public long put(long k, long v)
- Specified by:
put
in 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:
remove
in interfaceit.unimi.dsi.fastutil.longs.Long2LongFunction
-
get
public long get(long k)
- Specified by:
get
in interfaceit.unimi.dsi.fastutil.longs.Long2LongFunction
-
containsKey
public boolean containsKey(long k)
- Specified by:
containsKey
in interfaceit.unimi.dsi.fastutil.longs.Long2LongFunction
- Specified by:
containsKey
in interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
- Overrides:
containsKey
in classit.unimi.dsi.fastutil.longs.AbstractLong2LongMap
-
containsValue
public boolean containsValue(long v)
- Specified by:
containsValue
in interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
- Overrides:
containsValue
in classit.unimi.dsi.fastutil.longs.AbstractLong2LongMap
-
getOrDefault
public long getOrDefault(long k, long defaultValue)
- Specified by:
getOrDefault
in interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
-
putIfAbsent
public long putIfAbsent(long k, long v)
- Specified by:
putIfAbsent
in interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
-
remove
public boolean remove(long k, long v)
- Specified by:
remove
in interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
-
replace
public boolean replace(long k, long oldValue, long v)
- Specified by:
replace
in interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
-
replace
public long replace(long k, long v)
- Specified by:
replace
in interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
-
computeIfAbsent
public long computeIfAbsent(long k, LongUnaryOperator mappingFunction)
- Specified by:
computeIfAbsent
in interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
-
computeIfAbsentNullable
public long computeIfAbsentNullable(long k, LongFunction<? extends Long> mappingFunction)
- Specified by:
computeIfAbsentNullable
in interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
-
computeIfPresent
public long computeIfPresent(long k, BiFunction<? super Long,? super Long,? extends Long> remappingFunction)
- Specified by:
computeIfPresent
in interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
-
compute
public long compute(long k, BiFunction<? super Long,? super Long,? extends Long> remappingFunction)
- Specified by:
compute
in interfaceit.unimi.dsi.fastutil.longs.Long2LongMap
-
merge
public long merge(long k, long v, BiFunction<? super Long,? super Long,? extends Long> remappingFunction)
- Specified by:
merge
in 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:
long2LongEntrySet
in 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(long)
-
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:
trim()
-
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
-
-