Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion library/src/scala/collection/mutable/Builder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 4 additions & 11 deletions library/src/scala/collection/mutable/HashTable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p/>
* 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
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/collection/mutable/MultiMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
*
Expand Down
17 changes: 8 additions & 9 deletions library/src/scala/collection/mutable/PriorityQueue.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
*
Expand Down
4 changes: 4 additions & 0 deletions library/src/scala/collection/mutable/Set.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
* ```
Expand Down
Loading