summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/collection/mutable/FlatHashTable.scala8
-rw-r--r--src/library/scala/collection/mutable/HashSet.scala3
-rw-r--r--src/library/scala/collection/mutable/LinkedHashSet.scala2
3 files changed, 12 insertions, 1 deletions
diff --git a/src/library/scala/collection/mutable/FlatHashTable.scala b/src/library/scala/collection/mutable/FlatHashTable.scala
index 51872909ec..49e5adbd54 100644
--- a/src/library/scala/collection/mutable/FlatHashTable.scala
+++ b/src/library/scala/collection/mutable/FlatHashTable.scala
@@ -16,6 +16,10 @@ package mutable
* This trait is used internally. It can be mixed in with various collections relying on
* hash table as an implementation.
*
+ * @coll flat hash table
+ *
+ * @define cannotStoreNull '''Note''': A $coll cannot store `null` elements.
+ *
* @since 2.3
*
* @tparam A the type of the elements contained in the flat hash table.
@@ -343,7 +347,9 @@ private[collection] object FlatHashTable {
// so that:
protected final def sizeMapBucketSize = 1 << sizeMapBucketBitSize
- protected def elemHashCode(elem: A) = if (elem == null) 0 else elem.hashCode()
+ protected def elemHashCode(elem: A) =
+ if (elem == null) throw new IllegalArgumentException("Flat hash tables cannot contain null elements.")
+ else elem.hashCode()
protected final def improve(hcode: Int) = {
// var h: Int = hcode + ~(hcode << 9)
diff --git a/src/library/scala/collection/mutable/HashSet.scala b/src/library/scala/collection/mutable/HashSet.scala
index 684faaabf6..a7b1fb477c 100644
--- a/src/library/scala/collection/mutable/HashSet.scala
+++ b/src/library/scala/collection/mutable/HashSet.scala
@@ -16,6 +16,8 @@ import collection.parallel.mutable.ParHashSet
/** This class implements mutable sets using a hashtable.
*
+ * $cannotStoreNull
+ *
* @author Matthias Zenger
* @author Martin Odersky
* @version 2.0, 31/12/2006
@@ -23,6 +25,7 @@ import collection.parallel.mutable.ParHashSet
*
* @tparam A the type of the elements contained in this set.
*
+ *
* @define Coll mutable.HashSet
* @define coll mutable hash set
* @define thatinfo the class of the returned collection. In the standard library configuration,
diff --git a/src/library/scala/collection/mutable/LinkedHashSet.scala b/src/library/scala/collection/mutable/LinkedHashSet.scala
index 922ff25276..2b83316623 100644
--- a/src/library/scala/collection/mutable/LinkedHashSet.scala
+++ b/src/library/scala/collection/mutable/LinkedHashSet.scala
@@ -15,6 +15,8 @@ import generic._
/** This class implements mutable sets using a hashtable.
* The iterator and all traversal methods of this class visit elements in the order they were inserted.
*
+ * $cannotStoreNull
+ *
* @author Matthias Zenger
* @author Martin Odersky
* @version 2.0, 31/12/2006