diff --git a/library/src/scala/collection/mutable/Builder.scala b/library/src/scala/collection/mutable/Builder.scala index 1f76d9131c97..7e19327bcea4 100644 --- a/library/src/scala/collection/mutable/Builder.scala +++ b/library/src/scala/collection/mutable/Builder.scala @@ -53,9 +53,14 @@ trait Builder[-A, +To] extends Growable[A] { self: Builder[A, To]^ => * 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 pseudocode: + * as specified by the following code: * + * ```scala sc-name:builder-sizehint-context sc-hidden + * val coll: scala.collection.IterableOnce[?] = ??? + * val delta: Int = 0 + * def sizeHint(size: Int): Unit = () * ``` + * ```scala sc-compile-with:builder-sizehint-context * if (coll.knownSize != -1) * if (coll.knownSize + delta <= 0) sizeHint(0) * else sizeHint(coll.knownSize + delta) diff --git a/library/src/scala/collection/mutable/HashTable.scala b/library/src/scala/collection/mutable/HashTable.scala index 77f3ecb70c2d..32085041b0d4 100644 --- a/library/src/scala/collection/mutable/HashTable.scala +++ b/library/src/scala/collection/mutable/HashTable.scala @@ -407,17 +407,10 @@ private[collection] object HashTable { protected[collection] def elemHashCode(key: KeyType) = key.## - /** Defer to a high-quality hash in [[scala.util.hashing]]. - * The goal is to distribute across bins as well as possible even if a hash code has low entropy at some bits. - *
- * OLD VERSION - quick, but bad for sequence 0-10000 - little entropy in higher bits - since 2003 - * ``` - * var h: Int = hcode + ~(hcode << 9) - * h = h ^ (h >>> 14) - * h = h + (h << 4) - * h ^ (h >>> 10) - * ``` - * the rest of the computation is due to SI-5293 + /** Defer to high-quality bit mixing in [[scala.util.hashing]]. + * The current implementation byte-swaps the original hash code and rotates it by a + * seed derived from the table size, to help spread entries across bins even when the + * original hash code has low entropy in some bits. * * @param hcode the original hash code to improve * @param seed the seed value derived from the table size, used to rotate the hash diff --git a/library/src/scala/collection/mutable/MultiMap.scala b/library/src/scala/collection/mutable/MultiMap.scala index ed92d3689d63..c2cbbbbb60b5 100644 --- a/library/src/scala/collection/mutable/MultiMap.scala +++ b/library/src/scala/collection/mutable/MultiMap.scala @@ -20,7 +20,7 @@ import language.experimental.captureChecking * This class is typically used as a mixin. It turns maps which map `K` * to `Set[V]` objects into multimaps that map `K` to `V` objects. * - * @example ``` + * @example ```scala sc:compile * // first import all necessary types from package `collection.mutable` * import collection.mutable.{ HashMap, MultiMap, Set } * diff --git a/library/src/scala/collection/mutable/PriorityQueue.scala b/library/src/scala/collection/mutable/PriorityQueue.scala index 4d955224d708..ea59c9df1aa9 100644 --- a/library/src/scala/collection/mutable/PriorityQueue.scala +++ b/library/src/scala/collection/mutable/PriorityQueue.scala @@ -47,17 +47,16 @@ import scala.math.Ordering * the invariant of the underlying heap-ordered tree. Note that [[clone]] * does not rebuild the underlying tree. * - * ``` - * scala> val pq = collection.mutable.PriorityQueue(1, 2, 5, 3, 7) - * val pq: scala.collection.mutable.PriorityQueue[Int] = PriorityQueue(7, 3, 5, 1, 2) + * ```scala sc:compile + * val pq = collection.mutable.PriorityQueue(1, 2, 5, 3, 7) + * // pq: scala.collection.mutable.PriorityQueue[Int] = PriorityQueue(7, 3, 5, 1, 2) * - * scala> pq.toList // also not in order - * val res0: List[Int] = List(7, 3, 5, 1, 2) - * - * scala> pq.clone.dequeueAll - * val res1: Seq[Int] = ArraySeq(7, 5, 3, 2, 1) - * ``` + * pq.toList // also not in order + * // res0: List[Int] = List(7, 3, 5, 1, 2) * + * pq.clone.dequeueAll + * // res1: Seq[Int] = ArraySeq(7, 5, 3, 2, 1) + * ``` * * @tparam A type of the elements in this priority queue. * @param ord implicit ordering used to compare the elements of type `A`. * diff --git a/library/src/scala/collection/mutable/Set.scala b/library/src/scala/collection/mutable/Set.scala index 31be0b11ae55..e464b627eedc 100644 --- a/library/src/scala/collection/mutable/Set.scala +++ b/library/src/scala/collection/mutable/Set.scala @@ -62,7 +62,11 @@ transparent trait SetOps[A, +CC[X], +C <: SetOps[A, CC, C]] * This method allows one to add or remove an element `elem` * from this set depending on the value of parameter `included`. * Typically, one would use the following syntax: + * ```scala sc-name:set-update-context sc-hidden + * val set = scala.collection.mutable.Set(1) + * val elem = 1 * ``` + * ```scala sc-compile-with:set-update-context * set(elem) = true // adds element * set(elem) = false // removes element * ```