scala.collection.immutable

trait Set

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

trait Set[A]
extends Iterable[A] with Set[A] with SetClass[A, Set] with SetTemplate[A, Set[A]]

A generic trait for immutable sets. Concrete set implementations have to provide functionality for the abstract methods in Set:

    def contains(elem: A): Boolean
    def iterator: Iterator[A]
    def + (elem: A): This
    def - (elem: A): This

where This is the type of the set.

Author
Matthias Zenger
Martin Odersky
Version
2.8
Direct Known Subclasses:
Enumeration.ValueSet, BitSet, HashSet, ListSet, Set.EmptySet, Set.Set1, Set.Set2, Set.Set3, Set.Set4, SetProxy, SortedSet

Method Summary
override def companion : Companion[Set]
The factory companion object that builds instances of class CC
override def hashCode : Int
Returns a hash code value for the object.
Methods inherited from SetTemplate
contains (abstract), + (abstract), - (abstract), newBuilder, isEmpty, apply, intersect, &, **, union, |, diff, &~, subsetOf, equals, stringPrefix, toString
Methods inherited from Subtractable
-, --, --
Methods inherited from Addable
+, ++, ++
Methods inherited from SetClass
empty
Methods inherited from Function1
compose, andThen
Methods inherited from IterableTemplate
iterator (abstract), elements, foreach, foldRight, reduceRight, toIterable, head, takeRight, dropRight, sameElements, toStream, view, view, first, firstOption, toSeq, projection
Methods inherited from TraversableClass
genericBuilder, unzip, flatten, transpose
Methods inherited from TraversableTemplate
thisCollection, nonEmpty, size, hasDefiniteSize, ++, ++, map, flatMap, filter, filterMap, filterNot, remove, partition, groupBy, forall, exists, count, find, foldLeft, /:, :\, reduceLeft, reduceLeftOption, reduceRightOption, headOption, tail, last, lastOption, init, take, drop, slice, takeWhile, dropWhile, span, splitAt, copyToBuffer, copyToArray, copyToArray, toArray, toList, toSequence, toSet, mkString, mkString, mkString, addString, addString, addString
Methods inherited from AnyRef
getClass, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Method Details
override def companion : Companion[Set]
The factory companion object that builds instances of class CC
Overrides
Iterable.companion, Set.companion

override def hashCode : Int
Returns a hash code value for the object.

The default hashing algorithm is platform dependent. Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

Returns
the hash code value for the object.