final class LongMap extends AnyRef
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 229 entries (approximately 500 million). The maximum capacity is 230, but performance will degrade rapidly as 2^30 is approached.
- Alphabetic
- By Inheritance
- LongMap
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new LongMap(defaultEntry: (Long) => Int, initialBufferSize: Int)
Creates a new
LongMap
with specified default values and initial buffer size. - new LongMap(initialBufferSize: Int)
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.
- new LongMap()
- new LongMap(defaultEntry: (Long) => Int, initialBufferSize: Int, initBlank: Boolean)
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def contains(key: Long): Boolean
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def foreachKey[A](f: (Long) => A): Unit
Applies a function to all keys of this map.
- def get(key: Long): Option[Int]
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def initializeTo(m: Int, ek: Int, zv: Int, mv: Int, sz: Int, vc: Int, kz: Array[Long], vz: Array[Int]): Unit
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def repack(): Unit
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. - def size: Int
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def update(key: Long, value: Int): Unit
Updates the map to include a new key-value pair.
Updates the map to include a new key-value pair.
This is the fastest way to add an entry to a
LongMap
. - final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()