This class implements mutable maps with Long keys based on a hash table with open addressing.
Basic map operations on single entries, including contains
and get
, are
typically substantially faster with LongMap
than HashMap. Methods that act
on the whole map, including foreach
and map
are not in general expected
to be faster than with a generic map, save for those that take particular
advantage of the internal structure of the map: foreachKey
,
foreachValue
, mapValuesNow
, and transformValues
.
Maps with open addressing may become less efficient at lookup after repeated
addition/removal of elements. Although LongMap
makes a decent attempt to
remain efficient regardless, calling repack
on a map that will no longer
have elements removed but will be used heavily may save both time and
storage space.
This map is not intended to contain more than 2^29 entries (approximately 500 million). The maximum capacity is 2^30, but performance will degrade rapidly as 2^30 is approached.
- Companion:
- object
Value members
Constructors
Creates a new LongMap
with an initial buffer of specified size.
Creates a new LongMap
with an initial buffer of specified size.
A LongMap can typically contain half as many elements as its buffer size before it requires resizing.
Concrete methods
Repacks the contents of this LongMap
for maximum efficiency of lookup.
Repacks the contents of this LongMap
for maximum efficiency of lookup.
For maps that undergo a complex creation process with both addition and
removal of keys, and then are used heavily with no further removal of
elements, calling repack
after the end of the creation can result in
improved performance. Repacking takes time proportional to the number of
entries in the map.