Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int hashCode() {
- int result = 0;
- for (int i=0; i<bits.length; ++i) {
- long word = bits[i];
- result += 64 * i * Long.bitCount(word) + weightedBitCount(word);
- }
- return result;
- }
- int weightedBitCount(long word) { // naive implementation
- int result = 0;
- for (int i=0; i<64; ++i) {
- if ((word & (1L << i)) != 0) {
- result += i;
- }
- }
- return result;
- }
Add Comment
Please, Sign In to add comment