- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
对于 put
和 get
操作 OpenHashMap
跑赢大盘HashMap
约5次:https://gist.github.com/1423303HashMap
时是否有任何情况应该优先于 OpenHashMap
?
最佳答案
您的代码与 OpenHashMap 的用例之一完全匹配。您的代码:
println ("scala OpenHashMap: " + time (warmup) {
val m = new scala.collection.mutable.OpenHashMap[Int,Int];
var i = 0;
var start = System.currentTimeMillis();
while(i<100000) { m.put(i,i);i=i+1;};
})
A mutable hash map based on an open hashing scheme. The precise scheme is undefined, but it should make a reasonable effort to ensure that an insert with consecutive hash codes is not unneccessarily penalised. In particular, mappings of consecutive integer keys should work without significant performance loss.
Chained hash tables with linked lists are popular because they require only basic data structures with simple algorithms, and can use simple hash functions that are unsuitable for other methods.
The cost of a table operation is that of scanning the entries of the selected bucket for the desired key. If the distribution of keys is sufficiently uniform, the average cost of a lookup depends only on the average number of keys per bucket—that is, on the load factor.
Chained hash tables remain effective even when the number of table entries n is much higher than the number of slots. Their performance degrades more gracefully (linearly) with the load factor. For example, a chained hash table with 1000 slots and 10,000 stored keys (load factor 10) is five to ten times slower than a 10,000-slot table (load factor 1); but still 1000 times faster than a plain sequential list, and possibly even faster than a balanced search tree.
For separate-chaining, the worst-case scenario is when all entries were inserted into the same bucket, in which case the hash table is ineffective and the cost is that of searching the bucket data structure. If the latter is a linear list, the lookup procedure may have to scan all its entries; so the worst-case cost is proportional to the number n of entries in the table.
关于scala - collection.mutable.OpenHashMap 与 collection.mutable.HashMap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8415812/
我正在研究 clojure 库,当时我注意到一个可变字段被注释为 ^:unsynchronized-mutable 。可变是可变的,但我不知道不同步部分意味着什么,所以我读了 docs ,其中包含:
对于 put和 get操作 OpenHashMap跑赢大盘HashMap约5次:https://gist.github.com/1423303 HashMap时是否有任何情况应该优先于 OpenHas
下面的代码打开一个 .txt 文件并计算词频。我正在看一本书,但我感到困惑: 我的问题在这里: filename := os.Args[1] frequencyForWord := map[strin
我正在尝试添加两个 BitSet对象在一起(改变其中之一)。这应该是位集的有效操作。但似乎唯一能做到这一点的操作是 ++= .查看源代码,这似乎并没有区别对待添加位集。 在 Scala 2.9.1 中
trait Output { fn write(&mut self, text: &str); } struct DummyOutput {} impl Output for DummyOut
我正在用函数改变字符串值(我知道这是非常不安全和危险的): public static void reverse(String s) { try { Field val = S
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: C++ 'mutable' keyword class student { mutable int r
在《Java并发实践》一书中,在谈到“锁定和可见性”时,作者说道: We can now give the other reason for the rule requiring all thread
我想知道如何在 C99 中基本上声明 (a const pointer to (a mutable pointer to (a const type)))。 假设我有这个调用站点: const uin
我在考c++,下面有一个奇怪的代码块,我看不懂。这里,i 是一个 int 而 code 是一个 char: [=,&i]()mutable { i++; code = 'b'; std::
编译: []{}; 这也是: []() mutable {}; 但是对于这段代码,编译器会向我抛出错误信息: [] mutable {}; ^~~~~~~ error: lambda requi
我编写了如下所示的映射,即我的 mutable.HashMap 实现。 class SampleMap() extends mutable.HashMap[String, (Any, BigInt)]
我理解事物的方式是“变量”一词指的是重新分配引用的能力。 “常量”意味着不能重新分配引用。本质上是 Java 中 final 与 not 的区别。 var something = new obj()
是否有一种优雅的方式来更新 Map 中已经存在的值? 这看起来太可怕了: val a = map.get ( something ) if ( a != null ) // case .. excus
我正在尝试从向量中删除元素(如果存在): use std::collections::HashMap; fn test(map: HashMap>, department: String, emplo
在尝试克隆可变集合时,我最初的方法是对 mutable.Cloneable 特征使用 clone() 方法。但是,这取决于创建引用副本的 java.Object.clone 实现,而不是深拷贝。通过测
在尝试克隆可变集合时,我最初的方法是对 mutable.Cloneable 特征使用 clone() 方法。但是,这取决于创建引用副本的 java.Object.clone 实现,而不是深拷贝。通过测
MultiMap 的 addBinding 似乎不保留绑定(bind)到同一键的值的插入顺序,因为它使用的底层机制是 HashSet。使用 MultiMap 保留插入顺序的惯用方法是什么? 最佳答案
当我尝试在可变 Map 中插入一个元素时,我希望这个元素插入到我的 Map 而不是返回 Map(如 PF,不可变对象(immutable对象) ecc ...)出于这个原因,我使用了可变集合,但在我的
我意识到结构是不可变的,改变结构是邪恶的,改变结构中值的正确方法是创建新实例。但是,我不清楚新实例与允许结构可变的内存和性能方面/问题。 假设我有结构, struct Vehicle { pu
我是一名优秀的程序员,十分优秀!