zoukankan      html  css  js  c++  java
  • ConcurrentHashMap 部分源码英文说明

    Spread 方法说明

        

    Spreads (XORs) higher bits of hash to lower and also forces top bit to 0. 

    将哈希值的高位扩展(异或)到低位,并强制将高位 置为0.

    Because the table uses power-of-two masking, sets of hashes that vary only in bits above the current mask will always collide. 

    因为列表使用的是掩码的二次幂,仅在二进制位上变化的哈希值集合将始终发生冲突。

    (Among known examples are sets of Float keys holding consecutive whole numbers in small tables.) 

    在已知的例子中,有一组在小表中保存连续整数的浮点键。

    So we apply a transform that spreads the impact of higher bits downward. 

    所以我们应用一个转换,用于把高位的影响扩张到低位

    There is a tradeoff between speed, utility, and quality of bit-spreading. 

    在位扩张上有一个位于速度、实用和质量的平衡

    Because many common sets of hashes are already reasonably distributed (so don't benefit from spreading), and because we use trees to handle large sets of collisions in bins, 

    因为许多普通hash集合已经合理的分布(所以未从扩张中获益),而且我们使用 红黑树 去处理位于同一个桶中的hash

    we just XOR some shifted bits in the cheapest possible way to reduce systematic lossage, 

    我们使用可能是最廉价的异或操作位数来减少系统性能损耗

    as well as to incorporate impact of the highest bits that would otherwise never be used in index calculations because of table bounds.

    以及合并高位的影响,否则可能会出现因为表边界导致计算出来的下标永远不会用到。

        static final int spread(int h) {

            return (h ^ (h >>> 16)) & HASH_BITS;

        }

    专业英文还真是难翻译

  • 相关阅读:
    Wampserver主机服务配置方法
    工作记录
    Shell教程
    简单教程
    java笔记
    四轴飞行器
    ace文档
    马尔科夫模型参考
    电子书搜索
    免费电子书
  • 原文地址:https://www.cnblogs.com/brave-rocker/p/13338062.html
Copyright © 2011-2022 走看看