scala.collection.immutable
trait Set

[source: `scala/collection/immutable/Set.scala`]

`` `trait` Set[A]
  `extends` Set[A]

  This class defines the interface for immutable sets. Operations on an immutable set leave the original set unchanged, and return a new set if needed.

  Concrete set implementations just have to provide functionality for the abstract methods in `scala.collection.Set` as well as for `+` and `-`.

  Note that abstract immutable.Set's are not covariant in their type parameter. This is because some implementations cannot support the `+` method for arbitrary types.

Author
  Matthias Zenger, Martin Odersky
Version
  1.1, 03/05/2004

Direct Known Subclasses:
  Enumeration.SetXX, EmptySet, HashSet, ListSet, Set1, Set2, Set3, Set4, SortedSet

Method Summary
`def` | ** (that : Set[A]) : Set[A] This method is an alias for `intersect`. It computes an intersection with set `that`. It removes all the elements that are not present in `that`.
`abstract def` | + (elem : A) : Set[A] Create a new set with an additional element.
`def` | + (elem1 : A, elem2 : A, elems : A*) : Set[A] Add two or more elements to this set.
`def` | ++ (elems : Iterator[A]) : Set[A] Add all the elements provided by an iterator to the set.
`def` | ++ (elems : Iterable[A]) : Set[A] Add all the elements provided by an iterator of the iterable object `elems` to the set.
`def` | - (elem1 : A, elem2 : A, elems : A*) : Set[A] Remove two or more elements from this set.
`abstract def` | - (elem : A) : Set[A] Remove a single element from a set.
`def` | -- (elems : Iterable[A]) : Set[A] Remove all the elements provided by an iterator of the iterable object `elems` from the set.
`def` | -- (elems : Iterator[A]) : Set[A] Remove all the elements provided by an iterator `elems` from the set.
`abstract def` | empty [B] : Set[B]
`def` | excl (elems : A*) : Set[A] `excl` removes many elements from the set.
`def` | excl (that : Iterable[A]) : Set[A] This method removes all the elements provided by an iterator of the iterable object `that` from the set.
`override def` | filter (p : (A) => Boolean) : Set[A] Method `filter` removes all elements from the set for which the predicate `p` yields the value `false`.
`override def` | flatMap [B](f : (A) => Iterable[B]) : Set[B] Applies the given function `f` to each element of this set, then forms the union of all results.
`def` | incl (elems : A*) : Set[A] `incl` can be used to add many elements to the set at the same time.
`def` | incl (that : Iterable[A]) : Set[A] This method will add all the elements provided by an iterator of the iterable object `that` to the set.
`def` | intersect (that : Set[A]) : Set[A] This method computes an intersection with set `that`. It removes all the elements that are not present in `that`.
`override def` | map [B](f : (A) => B) : Set[B] Returns the set resulting from applying the given function `f` to each element of this set.

Methods inherited from Set
size (abstract), contains (abstract), apply, isEmpty, subsetOf, equals, hashCode, toArray

Methods inherited from Collection
toString, stringPrefix

Methods inherited from Iterable
elements (abstract), concat, ++, takeWhile, dropWhile, take, drop, foreach, forall, exists, find, findIndexOf, indexOf, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, copyToBuffer, sameElements, toList, mkString, mkString, addString, addString, copyToArray, projection, hasDefiniteSize

Methods inherited from Function1
compose, andThen

Methods inherited from AnyRef
getClass, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized

Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf

Method Details

`abstract` `def` empty[B] : Set[B]

Returns
  an empty set of arbitrary element type

`abstract` `def` +(elem : A) : Set[A]

  Create a new set with an additional element.

`` `def` +(elem1 : A, elem2 : A, elems : A*) : Set[A]

  Add two or more elements to this set.

Parameters
  `elem1 -` the first element.
  `elem2 -` the second element.
  `elems -` the remaining elements.
Returns
  a new set with the elements added.

`` `def` ++(elems : Iterable[A]) : Set[A]

  Add all the elements provided by an iterator of the iterable object `elems` to the set.

Parameters
  `elems -` the iterable object containing the elements to be added
Returns
  a new set with the elements added.

`` `def` ++(elems : Iterator[A]) : Set[A]

  Add all the elements provided by an iterator to the set.

Parameters
  `elems -` the iterator containing the elements to be added
Returns
  a new set with the elements added.

@deprecated
`` `def` incl(elems : A*) : Set[A]

  `incl` can be used to add many elements to the set at the same time.

@deprecated
`` `def` incl(that : Iterable[A]) : Set[A]

  This method will add all the elements provided by an iterator of the iterable object `that` to the set.

Parameters
  `that -` ...

`abstract` `def` -(elem : A) : Set[A]

  Remove a single element from a set.

Parameters
  `elem -` the element to be removed
Returns
  a new set with the element removed.

`` `def` -(elem1 : A, elem2 : A, elems : A*) : Set[A]

  Remove two or more elements from this set.

Parameters
  `elem1 -` the first element.
  `elem2 -` the second element.
  `elems -` the remaining elements.
Returns
  a new set with the elements removed.

`` `def` --(elems : Iterable[A]) : Set[A]

  Remove all the elements provided by an iterator of the iterable object `elems` from the set.

Parameters
  `elems -` An iterable object containing the elements to remove from the set.
Returns
  a new set with the elements removed.

`` `def` --(elems : Iterator[A]) : Set[A]

  Remove all the elements provided by an iterator `elems` from the set.

Parameters
  `elems -` An iterator containing the elements to remove from the set.
Returns
  a new set with the elements removed.

@deprecated
`` `def` excl(elems : A*) : Set[A]

  `excl` removes many elements from the set.

@deprecated
`` `def` excl(that : Iterable[A]) : Set[A]

  This method removes all the elements provided by an iterator of the iterable object `that` from the set.

`` `def` intersect(that : Set[A]) : Set[A]

  This method computes an intersection with set `that`. It removes all the elements that are not present in `that`.

Parameters
  `that -` the set to intersect with

`` `def` **(that : Set[A]) : Set[A]

  This method is an alias for `intersect`. It computes an intersection with set `that`. It removes all the elements that are not present in `that`.

Parameters
  `that -` the set to intersect with

`override` `def` map[B](f : (A) => B) : Set[B]

  Returns the set resulting from applying the given function `f` to each element of this set.

Parameters
  `f -` function to apply to each element.
Returns
  a set containing `f(a0), ..., f(an)` if this set contains `a0, ..., an`.

`override` `def` flatMap[B](f : (A) => Iterable[B]) : Set[B]

  Applies the given function `f` to each element of this set, then forms the union of all results.

Parameters
  `f -` function to apply to each element.
Returns
  a set containing all elements in each `f(a0), ..., f(an)` if this set contains `a0, ..., an`.

`override` `def` filter(p : (A) => Boolean) : Set[A]

  Method `filter` removes all elements from the set for which the predicate `p` yields the value `false`.

Parameters
  `p -` The predicate used to filter the set