算法里面有很多 位操作,看 redis 源码,看到 src/dict.c 下一个函数: 1 2 3 4 5 6 7 8 9 10 11 /* Function to reverse bits. Algorithm from: * http://graphics.stanford.edu/~seander/bithacks.html#ReverseParallel */ static unsigned long rev(unsigned long v) { unsigned long s = CHAR_BIT * sizeof(v); // bit size; must be power of 2 unsigned long