可能重复:
了解奇怪的Java哈希函数
static int hash(int h) {
// This function ensures that hashCodes that differ only by
// constant multiples at each bit position have a bounded
// number of collisions (approximately 8 at default load factor).
h ^= (h >>> 20) ^ (h >>> 12);
return h ^ (h >>> 7) ^ (h >>> 4);
}
Run Code Online (Sandbox Code Playgroud)
我不太了解这种实现的算法原理.我可以参考的任何解释或任何资源?谢谢 !
UPDATE
谢谢大家的答案和资源.实际上我理解哈希是如何工作的,但不是知道这个代码将如何确保a bounded number of collisions,正如评论所说.有理论上的验证吗?
如果我push -f用来重叠最后一次提交,即A,在远程存储库上,其他人在推送之前已经拉了A.
无论如何要撤消这种情况,以免给别人带来麻烦?
push -f一个原始人 " 假装 "没有触及任何东西是否有用?
要么
git如何决定本地repo是否偏离远程跟踪?
根据C99,可能有填充位signed int 或unsigned int表示.所以我想知道还有任何实现有这样过时的东西吗?
我经常tip-bot for XXX在LKML(Linux内核邮件列表)中看到.这些邮件通常由提交组成.
我四处搜索,仍然没有找到'tip-bot'的含义.有人可以帮忙解释一下吗?
以下是Linux内核中用于per-cpu贵重物品的技巧.正如评论所说,它可以实现这两个目标:
1.强制范围.
2.确保独特性,即使是静态的.
以下是魔术的演奏方式(为简单起见,我认为是一些MACRO):
/*
* __pcpu_scope_* dummy variable is used to enforce scope. It
* receives the static modifier when it's used in front of
* DEFINE_PER_CPU() and will trigger build failure if
* DECLARE_PER_CPU() is used for the same variable.
*
* __pcpu_unique_* dummy variable is used to enforce symbol uniqueness
* such that hidden weak symbol collision, which will cause unrelated
* variables to share the same address, can be detected during build.
*/
#define DECLARE_PER_CPU_SECTION(type, name, …Run Code Online (Sandbox Code Playgroud) 我知道在 C 和 Java 中,float 的底层表示是 IEEE754-32,double 是 IEEE754-64。
在表达式中,float将自动提升为double. 又怎样?以 3.7f 为例。过程是这样的吗?
- 3.7f 将使用 IEEE754 在内存中表示。它适合 4 个字节。
- 在计算过程中,它可能被加载到一个64位寄存器(或任何64位的地方),把3.7f变成IEEE754-64表示。
这段代码来自linux内核源代码.$〜3究竟是什么意思?我知道$ 3意味着一个直接的数字,但是它带有一个前导符号〜?