scala.collection.immutable

class HashSet

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

@serializable

@SerialVersionUID(4020728942921483037L)

class HashSet[A]
extends Set[A] with GenericSetTemplate[A, HashSet] with SetLike[A, HashSet[A]] with FlatHashTable[A]

This class implements immutable sets using a hash table.

It is optimized for sequential accesses where the last updated table is accessed most often. It supports with reasonable efficiency accesses to previous versions of the table by keeping a change log that's regularly compacted. It needs to synchronize most methods, so it is less suitable for highly concurrent accesses.

Notes
the builder of a hash set returns specialized representations EmptySet,Set1,..., Set4 for sets of size <= 4.
Author
Martin Odersky
Version
2.8
Since
2.3
Value Summary
protected var changedElem : A
protected var deleted : Boolean
protected var later : HashSet[A]
Values and Variables inherited from FlatHashTable
table, tableSize, threshold
Method Summary
def + (elem : A) : HashSet[A]
Creates a new set with an additional element, unless the element is already present.
def - (elem : A) : HashSet[A]
Creates a new set with given element removed from this set, unless the element is not present.
override def companion : GenericCompanion[HashSet]
The factory companion object that builds instances of class CC
def contains (elem : A) : Boolean
Checks if this set contains element elem.
override def iterator : Iterator[A]
Creates a new iterator over all elements contained in this iterable object.
override def size : Int
The number of elements in this collection
Methods inherited from FlatHashTable
loadFactor, loadFactorDenum, initialSize, findEntry, containsEntry, addEntry, removeEntry, elemHashCode, improve, index, clearTable
Methods inherited from SetLike
newBuilder, isEmpty, apply, intersect, &, **, union, |, diff, &~, subsetOf, stringPrefix, toString, hashCode, equals
Methods inherited from Subtractable
-, --, --
Methods inherited from Addable
+, ++, ++
Methods inherited from GenericSetTemplate
empty
Methods inherited from Function1
compose, andThen
Methods inherited from IterableLike
thisCollection, toCollection, elements, foreach, forall, exists, find, foldRight, reduceRight, toIterable, head, take, slice, takeWhile, takeRight, dropRight, copyToArray, zip, zipAll, zipWithIndex, sameElements, toStream, canEqual, view, view, first, firstOption, projection
Methods inherited from GenericTraversableTemplate
genericBuilder, unzip, flatten, transpose
Methods inherited from TraversableLike
repr, nonEmpty, hasDefiniteSize, ++, ++, map, flatMap, filter, filterNot, partialMap, remove, partition, groupBy, count, foldLeft, /:, :\, reduceLeft, reduceLeftOption, reduceRightOption, sum, product, min, max, headOption, tail, last, lastOption, init, drop, dropWhile, span, splitAt, copyToBuffer, copyToArray, toArray, toList, toSeq, toIndexedSeq, toSet, mkString, mkString, mkString, addString, addString, addString, withFilter
Methods inherited from AnyRef
getClass, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Value Details
protected var later : HashSet[A]

protected var changedElem : A

protected var deleted : Boolean

Method Details
override def companion : GenericCompanion[HashSet]
The factory companion object that builds instances of class CC
Overrides
Set.companion

def contains(elem : A) : Boolean
Checks if this set contains element elem.
Parameters
elem - the element to check for membership.
Returns
true iff elem is contained in this set.
Overrides
SetLike.contains

def +(elem : A) : HashSet[A]
Creates a new set with an additional element, unless the element is already present.
Parameters
elem - the element to be added
Overrides
SetLike.+

def -(elem : A) : HashSet[A]
Creates a new set with given element removed from this set, unless the element is not present.
Parameters
elem - the element to be removed
Overrides
SetLike.-

override def size : Int
The number of elements in this collection

override def iterator : Iterator[A]
Creates a new iterator over all elements contained in this iterable object.
Returns
the new iterator
Overrides
FlatHashTable.iterator