有没有办法在 scala 2.8 中创建 IdentityMap

发布于 2024-09-11 03:44:06 字数 111 浏览 2 评论 0原文

collection.jcl 中曾经有一个 IdentityHashMap:有没有办法在新的 2.8 集合库中构造相同的东西(可能具有定制的相等关系)?

There used to be an IdentityHashMap in collection.jcl: is there a way of constructing the same thing in the new 2.8 collections library (perhaps with a bespoke equality-relation)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2024-09-18 03:44:07

在 scala.collection.mutable.HashMap 中有两个受保护的方法:elemEquals 和 elemHashCode。如果您覆盖它们,您可以创建自己的 IdentityHashMap

在 scala.collection.immutable.HashMap 中只有 elemHashCode。 (我不知道为什么,随口一说。)

In scala.collection.mutable.HashMap there are two protected methods, elemEquals and elemHashCode. If you override them you can create an IdentityHashMap of your own.

In scala.collection.immutable.HashMap there is only elemHashCode. (I don't know why, offhand.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文