HashMap调整大小方法的实现细节

HashMap调整大小方法的实现细节,第1张

HashMap调整大小方法的实现细节

设计注意事项已记录在同一源文件中的第211行的代码注释中

* When bin lists are treeified, split, or untreeified, we keep* them in the same relative access/traversal order (i.e., field* Node.next) to better preserve locality, and to slightly* simplify handling of splits and traversals that invoke* iterator.remove. When using comparators on insertion, to keep a* total ordering (or as close as is required here) across* rebalancings, we compare classes and identityHashCodes as* tie-breakers.

由于通过迭代器删除映射无法触发调整大小,因此专门保留顺序的原因

resize
是“更好地保留局部性,并稍微简化拆分的处理”,以及在策略上保持一致。



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5478894.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-12
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存