summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/SetLike.scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2015-04-01 16:47:22 +0200
committerLukas Rytz <lukas.rytz@gmail.com>2015-04-01 16:47:22 +0200
commitdcd9a83916f9e0128ef6869def82d4f23bdea0e0 (patch)
treee58331aebe8ba06fd1c15faf36fdbb3f77b489b9 /src/library/scala/collection/SetLike.scala
parentebf0976c363c67e6a46c66d70b39704f1ce5e74a (diff)
parentfcc20fe4d3ac5caceb50965bc202b880e61f984c (diff)
downloadscala-dcd9a83916f9e0128ef6869def82d4f23bdea0e0.tar.gz
scala-dcd9a83916f9e0128ef6869def82d4f23bdea0e0.tar.bz2
scala-dcd9a83916f9e0128ef6869def82d4f23bdea0e0.zip
Merge commit 'fcc20fe' into merge/2.11-to-2.12-apr-1
Diffstat (limited to 'src/library/scala/collection/SetLike.scala')
-rw-r--r--src/library/scala/collection/SetLike.scala30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/library/scala/collection/SetLike.scala b/src/library/scala/collection/SetLike.scala
index 80a344e6a8..d03c808c2c 100644
--- a/src/library/scala/collection/SetLike.scala
+++ b/src/library/scala/collection/SetLike.scala
@@ -116,22 +116,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)(_ + _)
@@ -180,7 +194,7 @@ self =>
*
* @return the iterator.
*/
- def subsets: Iterator[This] = new AbstractIterator[This] {
+ def subsets(): Iterator[This] = new AbstractIterator[This] {
private val elms = self.toIndexedSeq
private var len = 0
private var itr: Iterator[This] = Iterator.empty