summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/mutable/OpenHashMap.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-01-10 21:09:43 +0000
committerPaul Phillips <paulp@improving.org>2011-01-10 21:09:43 +0000
commit4af620886bd037910ca2cd637671f2f0e00c7a5a (patch)
treefc23370fa3a9453ee0c3bb92d1c895caecf51420 /src/library/scala/collection/mutable/OpenHashMap.scala
parent9558f60e7ae165e10b41f0649535e95fee255199 (diff)
downloadscala-4af620886bd037910ca2cd637671f2f0e00c7a5a.tar.gz
scala-4af620886bd037910ca2cd637671f2f0e00c7a5a.tar.bz2
scala-4af620886bd037910ca2cd637671f2f0e00c7a5a.zip
Pulled some bit level operations into their own...
Pulled some bit level operations into their own file. It's pretty much impossible to abstract across Int and Long with no penalty, but we can at least have duplicated code in the same place to minimize the challenge. No review.
Diffstat (limited to 'src/library/scala/collection/mutable/OpenHashMap.scala')
-rw-r--r--src/library/scala/collection/mutable/OpenHashMap.scala22
1 files changed, 3 insertions, 19 deletions
diff --git a/src/library/scala/collection/mutable/OpenHashMap.scala b/src/library/scala/collection/mutable/OpenHashMap.scala
index 9c31cc5a6f..29dfc3ad19 100644
--- a/src/library/scala/collection/mutable/OpenHashMap.scala
+++ b/src/library/scala/collection/mutable/OpenHashMap.scala
@@ -6,12 +6,9 @@
** |/ **
\* */
-
-
package scala.collection
package mutable
-
/**
* @define Coll OpenHashMap
* @define coll open hash map
@@ -19,29 +16,16 @@ package mutable
* @since 2.7
*/
object OpenHashMap {
- def apply[K, V](elems : (K, V)*) = {
- val dict = new OpenHashMap[K, V];
- elems.foreach({case (x, y) => dict(x) = y});
- dict;
- }
+ import generic.BitOperations.Int.highestOneBit
- def empty[K, V] = new OpenHashMap[K, V];
+ def apply[K, V](elems : (K, V)*) = new OpenHashMap[K, V] ++= elems
+ def empty[K, V] = new OpenHashMap[K, V]
final private class OpenEntry[Key, Value](val key: Key,
val hash: Int,
var value: Option[Value])
extends HashEntry[Key, OpenEntry[Key, Value]]
- private[mutable] def highestOneBit(j : Int) = { // This should really go somewhere central as we're now code sharing by cut and paste. :(
- var i = j;
- i |= (i >> 1);
- i |= (i >> 2);
- i |= (i >> 4);
- i |= (i >> 8);
- i |= (i >> 16);
- i - (i >>> 1);
- }
-
private[mutable] def nextPowerOfTwo(i : Int) = highestOneBit(i) << 1;
}