Here you can find the source of hashCode(long x)
Parameter | Description |
---|---|
x | Bitset bitset |
public static int hashCode(long x)
//package com.java2s; /*/*from w w w . j a va 2s. co m*/ This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures Copyright (C) 2015 Ludwig-Maximilians-Universit?t M?nchen Lehr- und Forschungseinheit f?r Datenbanksysteme ELKI Development Team This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Compute a hash code for the given bitset. * * @param x Bitset bitset * @return Hash code */ public static int hashCode(long x) { // We use almost the same hash code function as Java BitSet. // Optimized for speed only, not protected against collision attacks // If you need that, consider using murmur hashing with custom seeds. long hash = 0x76543210L ^ x; return (int) ((hash >> 32) ^ hash); } /** * Compute a hash code for the given bitset. * * @param x Bitset bitset * @return Hash code */ public static int hashCode(long[] x) { // We use almost the same hash code function as Java BitSet. // Optimized for speed only, not protected against collision attacks // If you need that, consider using murmur hashing with custom seeds. long hash = 0x76543210L; for (int i = 0; i < x.length;) { hash ^= x[i] * ++i; } return (int) ((hash >> 32) ^ hash); } }