summaryrefslogtreecommitdiff
path: root/src/library/scalax/collection/mutable/HashSet.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/scalax/collection/mutable/HashSet.scala')
-rw-r--r--src/library/scalax/collection/mutable/HashSet.scala48
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
+}
+
+