summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-11-22 12:37:39 +0000
committerAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-11-22 12:37:39 +0000
commitc6f4dac7beec147982c91e8129834b2b50299c82 (patch)
tree2a6a3d6a6ff4c387da0ba2d9a0022d8ece369c25 /src
parente3cfb4216f89dfba3db1e6fd3bb7b985ee11c924 (diff)
downloadscala-c6f4dac7beec147982c91e8129834b2b50299c82.tar.gz
scala-c6f4dac7beec147982c91e8129834b2b50299c82.tar.bz2
scala-c6f4dac7beec147982c91e8129834b2b50299c82.zip
Fixes #3630.
Review by extempore.
Diffstat (limited to 'src')
-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