ChunkMapBuilder
A mutable builder for constructing instances of ChunkMap.
This builder allows efficient assembly of a ChunkMap by enabling progressive addition of key-value pairs. Duplicate keys are supported; in case of duplicates, the latest associated value overwrites the previous value.
Type parameters
- K
-
The type of keys in the map.
- V
-
The type of values in the map.
Value parameters
- initCapacity
-
The initial capacity for the internal storage of keys and values. Defaults to 4 if not explicitly provided. Methods:
addOne: Adds a single key-value pair to the map being built.clear: Clears all key-value pairs from the builder, resetting its state.knownSize: Returns the current size of the map being built.result: Finalizes the construction and produces an immutableChunkMapinstance.sizeHint: Provides a size hint to optimize internal storage for a specified number of elements.
Attributes
- Constructor
-
Initializes the builder with a specified initial capacity for internal buffers.
- Source
- ChunkMap.scala
- Graph
-
- Supertypes
Members list
Value members
Concrete methods
Adds a key-value pair to the builder.
Adds a key-value pair to the builder.
If the key already exists, its associated value is updated.
Attributes
- Source
- ChunkMap.scala
Adds a key-value pair to the builder.
Adds a key-value pair to the builder.
If the key already exists, its associated value is updated.
Attributes
- Definition Classes
-
Growable
- Source
- ChunkMap.scala
Removes all elements from the builder and resets its size to zero.
Removes all elements from the builder and resets its size to zero.
Attributes
- Definition Classes
-
Builder -> Clearable
- Source
- ChunkMap.scala
Returns the number of elements in the builder.
Returns the number of elements in the builder.
Attributes
- Definition Classes
-
Growable
- Source
- ChunkMap.scala
Constructs and returns a new ChunkMap containing the key-value pairs added to the builder.
Constructs and returns a new ChunkMap containing the key-value pairs added to the builder.
Attributes
- Definition Classes
-
Builder
- Source
- ChunkMap.scala
Adjusts the internal storage size to accommodate the specified hint, if necessary.
Adjusts the internal storage size to accommodate the specified hint, if necessary.
Attributes
- Definition Classes
-
Builder
- Source
- ChunkMap.scala
Inherited methods
Alias for addAll.
Alias for addOne.
Add s all elements produced by an IterableOnce to this growable collection.
Add s all elements produced by an IterableOnce to this growable collection.
Value parameters
- elems
-
the IterableOnce producing the elements to add.
Attributes
- Returns
-
the growable collection itself.
- Inherited from:
- Growable
- Source
- Growable.scala
A builder resulting from this builder by mapping the result using f.
A builder resulting from this builder by mapping the result using f.
Type parameters
- NewTo
-
the type of collection produced by the returned builder
Value parameters
- f
-
the function to apply to this builder's result
Attributes
- Inherited from:
- Builder
- Source
- Builder.scala
Gives a hint that the result of this builder is expected to have the same size as the given collection, plus some delta.
Gives a hint that the result of this builder is expected to have the same size as the given collection, plus some delta.
This method provides a hint only if the collection has a known size, as specified by the following code:
val coll: scala.collection.IterableOnce[?] = ???
val delta: Int = 0
def sizeHint(size: Int): Unit = ()
if (coll.knownSize != -1)
if (coll.knownSize + delta <= 0) sizeHint(0)
else sizeHint(coll.knownSize + delta)
If the delta is negative and the result size is known to be negative, then the size hint is issued at zero.
Some builder classes will optimize their representation based on the hint. However, builder implementations are required to work correctly even if the hint is wrong, i.e., if a different number of elements is added.
Value parameters
- coll
-
the collection which serves as a hint for the result's size.
- delta
-
a correction to add to the
coll.sizeto produce the size hint (zero if omitted).
Attributes
- Inherited from:
- Builder
- Source
- Builder.scala
Gives a hint how many elements are expected to be added when the next result is called, together with an upper bound given by the size of some other collection. Some builder classes will optimize their representation based on the hint. However, builder implementations are still required to work correctly even if the hint is wrong, i.e. a different number of elements is added.
Gives a hint how many elements are expected to be added when the next result is called, together with an upper bound given by the size of some other collection. Some builder classes will optimize their representation based on the hint. However, builder implementations are still required to work correctly even if the hint is wrong, i.e. a different number of elements is added.
Value parameters
- boundingColl
-
the bounding collection. If it is an IndexedSeqLike, then sizes larger than collection's size are reduced.
- size
-
the hint how many elements will be added.
Attributes
- Inherited from:
- Builder
- Source
- Builder.scala
Deprecated and Inherited methods
Add s two or more elements to this growable collection.
Add s two or more elements to this growable collection.
Value parameters
- elem1
-
the first element to add.
- elem2
-
the second element to add.
- elems
-
the remaining elements to add.
Attributes
- Returns
-
the growable collection itself
- Deprecated
-
[Since version 2.13.0]Use `++=` aka `addAll` instead of varargs `+=`; infix operations with an operand of multiple args will be deprecated - Inherited from:
- Growable
- Source
- Growable.scala