diff options
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/collection/SetLike.scala | 28 | ||||
-rw-r--r-- | src/library/scala/util/Random.scala | 10 |
2 files changed, 29 insertions, 9 deletions
diff --git a/src/library/scala/collection/SetLike.scala b/src/library/scala/collection/SetLike.scala index 31465bb619..f8ac1d754d 100644 --- a/src/library/scala/collection/SetLike.scala +++ b/src/library/scala/collection/SetLike.scala @@ -107,22 +107,36 @@ self => */ def + (elem: A): This - /** Creates a new $coll with additional elements. + /** Creates a new $coll with additional elements, omitting duplicates. * - * This method takes two or more elements to be added. Another overloaded - * variant of this method handles the case where a single element is added. + * This method takes two or more elements to be added. Elements that already exist in the $coll will + * not be added. Another overloaded variant of this method handles the case where a single element is added. + * + * Example: + * {{{ + * scala> val a = Set(1, 3) + 2 + 3 + * a: scala.collection.immutable.Set[Int] = Set(1, 3, 2) + * }}} * * @param elem1 the first element to add. * @param elem2 the second element to add. * @param elems the remaining elements to add. - * @return a new $coll with the given elements added. + * @return a new $coll with the given elements added, omitting duplicates. */ def + (elem1: A, elem2: A, elems: A*): This = this + elem1 + elem2 ++ elems - /** Creates a new $coll by adding all elements contained in another collection to this $coll. + /** Creates a new $coll by adding all elements contained in another collection to this $coll, omitting duplicates. + * + * This method takes a collection of elements and adds all elements, omitting duplicates, into $coll. + * + * Example: + * {{{ + * scala> val a = Set(1, 2) ++ Set(2, "a") + * a: scala.collection.immutable.Set[Any] = Set(1, 2, a) + * }}} * - * @param elems the collection containing the added elements. - * @return a new $coll with the given elements added. + * @param elems the collection containing the elements to add. + * @return a new $coll with the given elements added, omitting duplicates. */ def ++ (elems: GenTraversableOnce[A]): This = (repr /: elems.seq)(_ + _) diff --git a/src/library/scala/util/Random.scala b/src/library/scala/util/Random.scala index 8d68c5be38..2d38c9d4a0 100644 --- a/src/library/scala/util/Random.scala +++ b/src/library/scala/util/Random.scala @@ -121,15 +121,21 @@ class Random(val self: java.util.Random) extends AnyRef with Serializable { (bf(xs) ++= buf).result() } + @deprecated("Preserved for backwards binary compatibility. To remove in 2.12.x.", "2.11.6") + final def `scala$util$Random$$isAlphaNum$1`(c: Char) = (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') + /** Returns a Stream of pseudorandomly chosen alphanumeric characters, * equally chosen from A-Z, a-z, and 0-9. * * @since 2.8 */ def alphanumeric: Stream[Char] = { - def isAlphaNum(c: Char) = (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') + def nextAlphaNum: Char = { + val chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" + chars charAt (self nextInt chars.length) + } - Stream continually nextPrintableChar filter isAlphaNum + Stream continually nextAlphaNum } } |