scala.collection

trait Set

[source: scala/collection/Set.scala]

trait Set[A]
extends (A) => Boolean with Collection[A]

A set is a collection that includes at most one of any object.

This trait provides a limited interface, only allowing reading of elements. There are two extensions of this trait, in packages scala.collection.mutable and scala.collection.immutable, which provide functionality for adding and removing objects from the set. The trait in the first package is for sets that are modified destructively, whereas the trait in the second package is for immutable sets which create a new set when something is added or removed to them.

Author
Matthias Zenger
Martin Odersky
Version
2.0, 01/01/2007
Direct Known Subclasses:
BitSet, SetProxy, SortedSet, Set, Set

Method Summary
def apply (elem : A) : Boolean
This method allows sets to be interpreted as predicates. It returns true, iff this set contains element elem.
abstract def contains (elem : A) : Boolean
Checks if this set contains element elem.
override def equals (that : Any) : Boolean
Compares this set with another object and returns true, iff the other object is also a set which contains the same elements as this set.
override def hashCode : Int
hashcode for this set
override def isEmpty : Boolean
Checks if this set is empty.
abstract def size : Int
Returns the number of elements in this set.
def subsetOf (that : Set[A]) : Boolean
Checks if this set is a subset of set that.
override def toArray [B >: A] : Array[B]
Converts this iterable to a fresh Array with elements.
Methods inherited from Collection
toString, stringPrefix
Methods inherited from Iterable
elements (abstract), concat, ++, map, flatMap, filter, takeWhile, dropWhile, take, drop, foreach, forall, exists, find, findIndexOf, indexOf, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, copyToBuffer, sameElements, toList, toStream, mkString, 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