diff options
author | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2011-06-20 13:36:24 +0000 |
---|---|---|
committer | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2011-06-20 13:36:24 +0000 |
commit | d2fd3d61d1cceb79c731a4be46977384c7cb7c9b (patch) | |
tree | 2cc87139c1804a66577db96d64e770d2e0398eac /src | |
parent | 2e29f1475ac750a75090f2b1c241814240043523 (diff) | |
download | scala-d2fd3d61d1cceb79c731a4be46977384c7cb7c9b.tar.gz scala-d2fd3d61d1cceb79c731a4be46977384c7cb7c9b.tar.bz2 scala-d2fd3d61d1cceb79c731a4be46977384c7cb7c9b.zip |
Fixed an overflow which occurs in hashtable siz...
Fixed an overflow which occurs in hashtable size computations. Fixes
#4678.
No review.
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/collection/mutable/FlatHashTable.scala | 2 | ||||
-rw-r--r-- | src/library/scala/collection/parallel/mutable/ParHashSet.scala | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/library/scala/collection/mutable/FlatHashTable.scala b/src/library/scala/collection/mutable/FlatHashTable.scala index d74c5f3c4d..3118d6aa31 100644 --- a/src/library/scala/collection/mutable/FlatHashTable.scala +++ b/src/library/scala/collection/mutable/FlatHashTable.scala @@ -323,7 +323,7 @@ private[collection] object FlatHashTable { */ private[collection] def initialSize: Int = 16 - private[collection] def sizeForThreshold(size: Int, _loadFactor: Int) = size * loadFactorDenum / _loadFactor + private[collection] def sizeForThreshold(size: Int, _loadFactor: Int) = (size.toLong * loadFactorDenum / _loadFactor).toInt private[collection] def newThreshold(_loadFactor: Int, size: Int) = { val lf = _loadFactor diff --git a/src/library/scala/collection/parallel/mutable/ParHashSet.scala b/src/library/scala/collection/parallel/mutable/ParHashSet.scala index 0e48995cbe..3e22e3cdd8 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashSet.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashSet.scala @@ -178,6 +178,8 @@ with collection.mutable.FlatHashTable.HashUtils[T] { threshold = FlatHashTable.newThreshold(_loadFactor, table.length) sizeMapInit(table.length) + override def toString = "AFHT(%s)".format(table.length) + def tableLength = table.length def setSize(sz: Int) = tableSize = sz @@ -194,7 +196,7 @@ with collection.mutable.FlatHashTable.HashUtils[T] { * the table will try to add the element in such a position if possible. Collisions are resolved * using linear hashing, so the element may actually have to be added to a position * that follows the specified one. In the case that the first unoccupied position - * comes after `comesBefore`, the element is not added and the method simply returns `-1`, + * comes after `comesBefore`, the element is not added and the method simply returns -1, * indicating that it couldn't add the element in a position that comes before the * specified one. * If the element is already present in the hash table, it is not added, and this method |