@@ -274,7 +274,10 @@ final class HashMap[K, +V] private[immutable] (private[immutable] val rootNode:
274274
275275 override def foreachEntry [U ](f : (K , V ) => U ): Unit = rootNode.foreachEntry(f)
276276
277- /** Applies a function to each key, value, and **original** hash value in this Map. */
277+ /** Applies a function to each key, value, and **original** hash value in this Map.
278+ *
279+ * @param f the function to apply to each key, value, and original hash triple
280+ */
278281 @ inline private [collection] def foreachWithHash (f : (K , V , Int ) => Unit ): Unit = rootNode.foreachWithHash(f)
279282
280283 override def equals (that : Any ): Boolean =
@@ -336,6 +339,8 @@ final class HashMap[K, +V] private[immutable] (private[immutable] val rootNode:
336339 * // HashMap(2 -> 1) is returned, but it could also have returned HashMap(2 -> 3)
337340 * ```
338341 *
342+ *
343+ * @tparam V1 the value type of the resulting HashMap, a supertype of `V`
339344 */
340345 def merged [V1 >: V ](that : HashMap [K , V1 ])(mergef : ((K , V ), (K , V1 )) => (K , V1 )): HashMap [K , V1 ] =
341346 if (mergef == null ) {
@@ -555,16 +560,18 @@ private[immutable] sealed abstract class MapNode[K, +V] extends Node[MapNode[K,
555560
556561 /** Returns a MapNode with the passed key-value assignment added
557562 *
563+ * @tparam V1 the value type of the returned node, a supertype of `V`
558564 * @param key the key to add to the MapNode
559565 * @param value the value to associate with `key`
560- * @param originalHash the original hash of `key`
566+ * @param originalHash the original hash code of `key` (via `key.##`)
561567 * @param hash the improved hash of `key`
562568 * @param shift the shift of the node (distanceFromRoot * BitPartitionSize)
563569 * @param replaceValue if true, then the value currently associated to `key` will be replaced with the passed value
564570 * argument.
565571 * if false, then the key will be inserted if not already present, however if the key is present
566572 * then the passed value will not replace the current value. That is, if `false`, then this
567573 * method has `update if not exists` semantics.
574+ * @return a new `MapNode` containing the updated key-value mapping
568575 */
569576 def updated [V1 >: V ](key : K , value : V1 , originalHash : Int , hash : Int , shift : Int , replaceValue : Boolean ): MapNode [K , V1 ]
570577
@@ -606,17 +613,30 @@ private[immutable] sealed abstract class MapNode[K, +V] extends Node[MapNode[K,
606613 *
607614 * `this` should be a node from `left` hashmap in `left.merged(right)(mergef)`
608615 *
616+ * @tparam V1 the value type of the merged result, a supertype of `V`
609617 * @param that node from the "right" HashMap. Must also be at the same "path" or "position" within the right tree,
610618 * as `this` is, within the left tree
619+ * @param builder the builder used to accumulate the merged key-value pairs
620+ * @param shift the bit-level offset into the hash code, equal to `depth * BitPartitionSize`
621+ * @param mergef the function used to resolve collisions between keys present in both nodes
611622 */
612623 def mergeInto [V1 >: V ](that : MapNode [K , V1 ], builder : HashMapBuilder [K , V1 ], shift : Int )(mergef : ((K , V ), (K , V1 )) => (K , V1 )): Unit
613624
614625 /** Returns the exact (equal by reference) key, and value, associated to a given key.
615626 * If the key is not bound to a value, then an exception is thrown
627+ *
628+ * @param key the key to look up
629+ * @param originalHash the original hash code of `key` (via `key.##`)
630+ * @param hash the improved hash of `key`
631+ * @param shift the bit-level offset into the hash code, equal to `depth * BitPartitionSize`
616632 */
617633 def getTuple (key : K , originalHash : Int , hash : Int , shift : Int ): (K , V )
618634
619- /** Adds all key-value pairs to a builder. */
635+ /** Adds all key-value pairs to a builder.
636+ *
637+ * @tparam V1 the value type of the target builder, a supertype of `V`
638+ * @param builder the builder to add the key-value pairs to
639+ */
620640 def buildTo [V1 >: V ](builder : HashMapBuilder [K , V1 ]): Unit
621641}
622642
@@ -784,13 +804,15 @@ private final class BitmapIndexedMapNode[K, +V](
784804 * If instead this method may not mutate the child node in which the to-be-updated key-value pair belongs, then
785805 * that child will be updated immutably, but the result will be mutably re-inserted as a child of this node.
786806 *
807+ * @tparam V1 the value type of the updated node, a supertype of `V`
787808 * @param key the key to update
788809 * @param value the value to set `key` to
789810 * @param originalHash key.##
790811 * @param keyHash the improved hash
812+ *
791813 * @param shallowlyMutableNodeMap bitmap of child nodes of this node, which can be shallowly mutated
792814 * during the call to this method
793- *
815+ * @param shift the bit-level offset into the hash code, equal to `depth * BitPartitionSize`
794816 * @return Int which is the bitwise OR of shallowlyMutableNodeMap and any freshly created nodes, which will be
795817 * available for mutations in subsequent calls.
796818 */
@@ -1023,6 +1045,7 @@ private final class BitmapIndexedMapNode[K, +V](
10231045
10241046 /** Variant of `copyAndMigrateFromInlineToNode` which mutates `this` rather than returning a new node.
10251047 *
1048+ * @tparam V1 the value type of the child node, a supertype of `V`
10261049 * @param bitpos the bit position of the data to migrate to node
10271050 * @param keyHash the improved hash of the key currently at `bitpos`
10281051 * @param node the node to place at `bitpos` beneath `this`
@@ -2171,9 +2194,17 @@ private final class MapKeyValueTupleHashIterator[K, V](rootNode: MapNode[K, V])
21712194 }
21722195}
21732196
2174- /** Used in HashMap[K, V]#removeAll(HashSet[K]). */
2197+ /** Used in HashMap[K, V]#removeAll(HashSet[K]).
2198+ *
2199+ * @tparam K the key type
2200+ * @param rootSetNode the root node of the `HashSet` whose keys are to be removed
2201+ */
21752202private final class MapNodeRemoveAllSetNodeIterator [K ](rootSetNode : SetNode [K ]) extends ChampBaseIterator [K , SetNode [K ]](rootSetNode) {
2176- /** Returns the result of immutably removing all keys in `rootSetNode` from `rootMapNode`. */
2203+ /** Returns the result of immutably removing all keys in `rootSetNode` from `rootMapNode`.
2204+ *
2205+ * @tparam V the value type of the map node
2206+ * @param rootMapNode the root node of the map from which keys will be removed
2207+ */
21772208 def removeAll [V ](rootMapNode : BitmapIndexedMapNode [K , V ]): BitmapIndexedMapNode [K , V ] = {
21782209 var curr = rootMapNode
21792210 while (curr.size > 0 && hasNext) {
@@ -2214,13 +2245,19 @@ object HashMap extends MapFactory[HashMap] {
22142245
22152246 /** Creates a new Builder which can be reused after calling `result()` without an
22162247 * intermediate call to `clear()` in order to build multiple related results.
2248+ *
2249+ * @tparam K the key type of the HashMap
2250+ * @tparam V the value type of the HashMap
22172251 */
22182252 def newBuilder [K , V ]: ReusableBuilder [(K , V ), HashMap [K , V ]] = new HashMapBuilder [K , V ]
22192253}
22202254
22212255
22222256/** A `Builder` for a `HashMap`.
22232257 * $multipleResults
2258+ *
2259+ * @tparam K the key type of the HashMap being built
2260+ * @tparam V the value type of the HashMap being built
22242261 */
22252262private [immutable] final class HashMapBuilder [K , V ] extends ReusableBuilder [(K , V ), HashMap [K , V ]] {
22262263 import MapNode ._
@@ -2247,7 +2284,12 @@ private[immutable] final class HashMapBuilder[K, V] extends ReusableBuilder[(K,
22472284 rootNode.getOrElse(key, originalHash, improve(originalHash), 0 , value)
22482285 }
22492286
2250- /** Inserts element `elem` into array `as` at index `ix`, shifting right the trailing elems. */
2287+ /** Inserts element `elem` into array `as` at index `ix`, shifting right the trailing elems.
2288+ *
2289+ * @param as the source array to insert into
2290+ * @param ix the zero-based index at which to insert `elem`
2291+ * @param elem the element to insert
2292+ */
22512293 private def insertElement (as : Array [Int ], ix : Int , elem : Int ): Array [Int ] = {
22522294 if (ix < 0 ) throw new ArrayIndexOutOfBoundsException
22532295 if (ix > as.length) throw new ArrayIndexOutOfBoundsException
@@ -2258,7 +2300,16 @@ private[immutable] final class HashMapBuilder[K, V] extends ReusableBuilder[(K,
22582300 result
22592301 }
22602302
2261- /** Inserts key-value into the bitmapIndexMapNode. Requires that this is a new key-value pair. */
2303+ /** Inserts key-value into the bitmapIndexMapNode. Requires that this is a new key-value pair.
2304+ *
2305+ * @tparam V1 the value type being inserted, a supertype of `V`
2306+ * @param bm the bitmap-indexed map node to mutate
2307+ * @param bitpos the bit position in the bitmap where the key-value pair should be inserted
2308+ * @param key the key to insert
2309+ * @param originalHash the original hash code of `key` (via `key.##`)
2310+ * @param keyHash the improved hash of `key`
2311+ * @param value the value to associate with `key`
2312+ */
22622313 private def insertValue [V1 >: V ](bm : BitmapIndexedMapNode [K , V ],bitpos : Int , key : K , originalHash : Int , keyHash : Int , value : V1 ): Unit = {
22632314 val dataIx = bm.dataIndex(bitpos)
22642315 val idx = TupleLength * dataIx
@@ -2281,7 +2332,15 @@ private[immutable] final class HashMapBuilder[K, V] extends ReusableBuilder[(K,
22812332 bm.cachedJavaKeySetHashCode += keyHash
22822333 }
22832334
2284- /** Upserts a key/value pair into mapNode, mutably. */
2335+ /** Upserts a key/value pair into mapNode, mutably.
2336+ *
2337+ * @param mapNode the map node to update in place
2338+ * @param key the key to insert or update
2339+ * @param value the value to associate with `key`
2340+ * @param originalHash the original hash code of `key` (via `key.##`)
2341+ * @param keyHash the improved hash of `key`
2342+ * @param shift the bit-level offset into the hash code, equal to `depth * BitPartitionSize`
2343+ */
22852344 private [immutable] def update (mapNode : MapNode [K , V ], key : K , value : V , originalHash : Int , keyHash : Int , shift : Int ): Unit = {
22862345 mapNode match {
22872346 case bm : BitmapIndexedMapNode [K , V ] =>
0 commit comments