diff options
author | Martin Odersky <odersky@gmail.com> | 2009-02-13 11:59:49 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2009-02-13 11:59:49 +0000 |
commit | 04840e2ed4530df9a5ca59b984bf2b37a976dc70 (patch) | |
tree | 61394762e202f8ab60e0d3a8e8ac688404241bc3 /src/library/scalax/collection/mutable/HashSet.scala | |
parent | 708baf94764e2a839e24ca6204060a8d0664d88c (diff) | |
download | scala-04840e2ed4530df9a5ca59b984bf2b37a976dc70.tar.gz scala-04840e2ed4530df9a5ca59b984bf2b37a976dc70.tar.bz2 scala-04840e2ed4530df9a5ca59b984bf2b37a976dc70.zip |
new version of collection libraries
Diffstat (limited to 'src/library/scalax/collection/mutable/HashSet.scala')
-rw-r--r-- | src/library/scalax/collection/mutable/HashSet.scala | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/library/scalax/collection/mutable/HashSet.scala b/src/library/scalax/collection/mutable/HashSet.scala new file mode 100644 index 0000000000..601d0885c0 --- /dev/null +++ b/src/library/scalax/collection/mutable/HashSet.scala @@ -0,0 +1,48 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: HashSet.scala 16893 2009-01-13 13:09:22Z cunei $ + + +package scalax.collection.mutable + +import generic.{SetTemplate, SetFactory, AddableBuilder} + +/** Factory object for `HashSet` class */ +object HashSet extends SetFactory[HashSet] { + /** The empty set of this type */ + def empty[A] = new HashSet[A] +} + +/** This class implements mutable sets using a hashtable. + * + * @author Matthias Zenger + * @author Martin Odersky + * @version 2.0, 31/12/2006 + */ +@serializable +class HashSet[A] + extends Set[A] + with SetTemplate[HashSet, A] + with FlatHashTable[A] { + + def contains(elem: A): Boolean = containsEntry(elem) + + def +=(elem: A) { addEntry(elem) } + + def -=(elem: A) { removeEntry(elem) } + + override def clear() = super.clear() + + override def newBuilder[B]: generic.Builder[HashSet, B] = + new AddableBuilder[HashSet, B](HashSet.empty) + + override def clone(): HashSet[A] = new HashSet[A] ++ this +} + + |