【问题标题】:What is the reason to have two different Maps with the same addressing scheme?有两个具有相同寻址方案的不同 Map 的原因是什么?
【发布时间】:2019-06-22 22:53:39
【问题描述】:

我正在查看 scala.collection.mutable 地图,发现有 3 种不同类型的 Maps 具有开放寻址方案:

  1. OpenHashMap
  2. LongMap
  3. AnyRefMap

很明显,在Longs 的情况下,我们可能可以利用它并执行一些优化。但是OpenHashMapAnyRefMap 的意义还不是很清楚。

据我所知,针对geting 优化的开放式寻址方案,因为我们的缓存未命中率较低。

所以对于Longs,我们有LongMap 用于参考AnyRefMap。我们为什么要使用OpenHashMap

【问题讨论】:

    标签: scala collections hashmap


    【解决方案1】:

    不,没有理由使用OpenHashMap。它已在 Scala 2.13 中被弃用:https://www.scala-lang.org/files/archive/api/2.13.0/scala/collection/mutable/OpenHashMap.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-05
      • 2022-11-22
      • 1970-01-01
      • 2019-12-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多