-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Collection mutable (2): filled in @param, @tparam, and @return tags that were missed last time #26120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Collection mutable (2): filled in @param, @tparam, and @return tags that were missed last time #26120
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -138,6 +138,7 @@ class ArrayBuffer[A] private (initialElements: Array[AnyRef], initialSize: Int) | |
| /** Clears this buffer and shrinks to @param size (rounding up to the next | ||
| * natural size) | ||
| * @param size | ||
| * @return this `ArrayBuffer`, now empty and resized to a capacity at least as large as `size` | ||
| */ | ||
| def clearAndShrink(size: Int = ArrayBuffer.DefaultInitialSize): this.type = { | ||
| clear() | ||
|
|
@@ -211,6 +212,9 @@ class ArrayBuffer[A] private (initialElements: Array[AnyRef], initialSize: Int) | |
|
|
||
| /** Note: This does not actually resize the internal representation. | ||
| * See trimToSize if you want to also resize internally | ||
| * | ||
| * @param index the zero-based position of the element to remove | ||
| * @return the element that was removed at position `index` | ||
| */ | ||
| def remove(@deprecatedName("n", "2.13.0") index: Int): A = { | ||
| checkWithinBounds(index, index + 1) | ||
|
|
@@ -222,6 +226,9 @@ class ArrayBuffer[A] private (initialElements: Array[AnyRef], initialSize: Int) | |
|
|
||
| /** Note: This does not actually resize the internal representation. | ||
| * See trimToSize if you want to also resize internally | ||
| * | ||
| * @param index the zero-based position of the first element to remove | ||
| * @param count the number of elements to remove; a negative value throws `IllegalArgumentException` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are we missing a |
||
| */ | ||
| def remove(@deprecatedName("n", "2.13.0") index: Int, count: Int): Unit = | ||
| if (count > 0) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -585,16 +585,16 @@ transparent trait ArrayDequeOps[A, +CC[_] <: caps.Pure, +C <: AnyRef] extends St | |||||
| if (idx < 0 || idx >= until) | ||||||
| throw CommonErrors.indexOutOfBounds(index = idx, max = until - 1) | ||||||
|
|
||||||
| /** | ||||||
| * This is a more general version of copyToArray - this also accepts a srcStart unlike copyToArray | ||||||
| * This copies maxItems elements from this collections srcStart to dest's destStart | ||||||
| * If we reach the end of either collections before we could copy maxItems, we simply stop copying | ||||||
| * | ||||||
| * @param dest | ||||||
| * @param srcStart | ||||||
| * @param destStart | ||||||
| * @param maxItems | ||||||
| */ | ||||||
| /** This is a more general version of copyToArray - this also accepts a srcStart unlike copyToArray | ||||||
| * This copies maxItems elements from this collection's srcStart to dest's destStart | ||||||
| * If we reach the end of either collections before we could copy maxItems, we simply stop copying | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| * | ||||||
| * @param dest | ||||||
| * @param srcStart | ||||||
| * @param destStart | ||||||
| * @param maxItems | ||||||
| * @return the `dest` array, after the copied elements have been written into it | ||||||
| */ | ||||||
| def copySliceToArray(srcStart: Int, dest: Array[?], destStart: Int, maxItems: Int): dest.type = { | ||||||
| requireBounds(destStart, dest.length+1) | ||||||
| val toCopy = Math.min(maxItems, Math.min(length - srcStart, dest.length - destStart)) | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,7 @@ import scala.runtime.Statics | |
| * @tparam V the type of the values associated with the keys | ||
| * @param initialCapacity the initial capacity of the internal hash table | ||
| * @param loadFactor the load factor for the hash table, used to determine when to resize | ||
| * @param ordering the `Ordering` used to compare keys within a bucket's red-black tree | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does it make sense to mention the red-black tree, or is that just an implementation detail? |
||
| */ | ||
| final class CollisionProofHashMap[K, V](initialCapacity: Int, loadFactor: Double)(implicit ordering: Ordering[K]) | ||
| extends AbstractMap[K, V] | ||
|
|
@@ -714,6 +715,7 @@ final class CollisionProofHashMap[K, V](initialCapacity: Int, loadFactor: Double | |
| * @param _root the root of the red-black tree | ||
| * @param to the node to be replaced in the tree | ||
| * @param from the node that replaces `to` | ||
| * @return the (possibly updated) root of the tree, which differs from `_root` only when `to` was the root | ||
| */ | ||
| private def transplant(_root: RBNode, to: RBNode, from: RBNode): RBNode = { | ||
| var root = _root | ||
|
|
@@ -859,6 +861,7 @@ object CollisionProofHashMap extends SortedMapFactory[CollisionProofHashMap] { | |
| * @tparam A the key type of the tree nodes | ||
| * @tparam B the value type of the tree nodes | ||
| * @param node the node whose successor is to be found | ||
| * @return the in-order successor of `node`, or `null` if `node` is the last node in the traversal | ||
| */ | ||
| private def successor[A, B](node: RBNode[A, B]): RBNode[A, B] | Null = { | ||
| if (node.right ne null) minNodeNonNull(node.right) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,12 +65,14 @@ class HashMap[K, V](initialCapacity: Int, loadFactor: Double) | |
| /** Performs the inverse operation of improveHash. In this case, it happens to be identical to improveHash. | ||
| * | ||
| * @param improvedHash the improved hash value to convert back to the original `any.##` hash | ||
| * @return the original `any.##` hash code corresponding to `improvedHash` | ||
| */ | ||
| @`inline` private[collection] def unimproveHash(improvedHash: Int): Int = improveHash(improvedHash) | ||
|
|
||
| /** Computes the improved hash of an original (`any.##`) hash. | ||
| * | ||
| * @param originalHash the original hash code from `any.##` | ||
| * @return the improved hash with the high 16 bits xored into the low 16 bits | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consistency: xor vs XOR (I think I prefer XOR, but regardless, it should be consistent) |
||
| */ | ||
| @`inline` private def improveHash(originalHash: Int): Int = { | ||
| // Improve the hash by xoring the high 16 bits into the low 16 bits just in case entropy is skewed towards the | ||
|
|
@@ -86,6 +88,7 @@ class HashMap[K, V](initialCapacity: Int, loadFactor: Double) | |
| /** Computes the improved hash of this key. | ||
| * | ||
| * @param o the key for which to compute the improved hash | ||
| * @return the improved hash code of `o` (i.e., `improveHash(o.##)`) | ||
| */ | ||
| @`inline` private def computeHash(o: K): Int = improveHash(o.##) | ||
|
|
||
|
|
@@ -235,6 +238,7 @@ class HashMap[K, V](initialCapacity: Int, loadFactor: Double) | |
| * @param value the value to add | ||
| * @param hash the **improved** hashcode of `key` (see computeHash) | ||
| * @param getOld if true, then the previous value for `key` will be returned, otherwise, false | ||
| * @return `Some` wrapping the previous value if `getOld` is true and `key` was already present; `null` otherwise (i.e., when `getOld` is false or `key` was not in the map) | ||
| */ | ||
| private def put0(key: K, value: V, hash: Int, getOld: Boolean): Some[V] | Null = { | ||
| if(contentSize + 1 >= threshold) growTable(table.length * 2) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optimized?