scala.collection.mutable

class HashSet

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

@serializable

class HashSet[A]
extends Set[A] with SetClass[A, HashSet] with MutableSetTemplate[A, HashSet[A]] with FlatHashTable[A]
This class implements mutable sets using a hashtable.
Author
Matthias Zenger
Martin Odersky
Version
2.0, 31/12/2006
Values and Variables inherited from FlatHashTable
table, tableSize, threshold
Method Summary
def += (elem : A) : HashSet[A]
Adds a new element to the set.
def -= (elem : A) : HashSet[A]
Removes a single element from a set.
override def add (elem : A) : Boolean
Adds a new element to the set.
override def clear : Unit
Removes all elements from the set. After this operation is completed, the set will be empty.
override def clone : Set[A]
This method creates and returns a copy of the receiver object.
override def companion : Companion[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 foreach [U](f : (A) => U) : Unit
Apply a function f to all elements of this traversable object.
override def remove (elem : A) : Boolean
Removes a single element from a set.
override def size : Int
Returns the number of entires in this hash table.
Methods inherited from FlatHashTable
loadFactor, loadFactorDenum, initialSize, findEntry, containsEntry, addEntry, removeEntry, iterator, elemHashCode, improve, index
Methods inherited from Unhashable
hashCode, identityHashCode
Methods inherited from MutableSetTemplate
newBuilder, update, retain, result, +, +, ++, ++, -, -, --, --, <<
Methods inherited from Shrinkable
-=, --=, --=
Methods inherited from Builder
sizeHint, mapResult
Methods inherited from Growable
+=, ++=, ++=
Methods inherited from SetTemplate
isEmpty, apply, intersect, &, **, union, |, diff, &~, subsetOf, equals, stringPrefix, toString
Methods inherited from SetClass
empty
Methods inherited from Function1
compose, andThen
Methods inherited from IterableTemplate
elements, 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, 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, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Method Details
override def companion : Companion[HashSet]
The factory companion object that builds instances of class CC
Overrides
Set.companion

override def size : Int
Returns the number of entires in this hash table.
Overrides
FlatHashTable.size

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.

def +=(elem : A) : HashSet[A]
Adds a new element to the set.
Parameters
elem - the element to be added
Overrides
MutableSetTemplate.+=

def -=(elem : A) : HashSet[A]
Removes a single element from a set.
Parameters
elem - The element to be removed.
Overrides
MutableSetTemplate.-=

override def add(elem : A) : Boolean
Adds a new element to the set.
Parameters
elem - the element to be added
Returns
true if the element was not yet present in the set.
Overrides
MutableSetTemplate.add

override def remove(elem : A) : Boolean
Removes a single element from a set.
Parameters
elem - The element to be removed.
Returns
true if the element was already present in the set.
Overrides
MutableSetTemplate.remove

override def clear : Unit
Removes all elements from the set. After this operation is completed, the set will be empty.
Overrides
MutableSetTemplate.clear, FlatHashTable.clear

override def foreach[U](f : (A) => U) : Unit
Apply a function f to all elements of this traversable object.
Parameters
f - A function that is applied for its side-effect to every element. The result (of arbitrary type U) of function `f` is discarded.
Notes
This method underlies the implementation of most other bulk operations. Implementing `foreach` with `iterator` is often suboptimal. So `foreach` should be overridden in concrete collection classes if a more efficient implementation is available.

override def clone : Set[A]
This method creates and returns a copy of the receiver object.

The default implementation of the clone method is platform dependent.

Returns
a copy of the receiver object.

Overrides
MutableSetTemplate.clone