|
What this is
Other links
The source code// Copyright (c) 1999 CERN - European Organization for Nuclear Research. // Permission to use, copy, modify, distribute and sell this software and // its documentation for any purpose is hereby granted without fee, // provided that the above copyright notice appear in all copies and that // both that copyright notice and this permission notice appear in // supporting documentation. CERN makes no representations about the // suitability of this software for any purpose. It is provided "as is" // without expressed or implied warranty. package gnu.trove; /** * Provides various hash functions. * * @author wolfgang.hoschek@cern.ch * @version 1.0, 09/24/99 */ public final class HashFunctions { /** * Returns a hashcode for the specified value. * * @return a hash code value for the specified value. */ public static final int hash(double value) { long bits = Double.doubleToLongBits(value); return (int)(bits ^ (bits >>> 32)); //return (int) Double.doubleToLongBits(value*663608941.737); //this avoids excessive hashCollisions in the case values are //of the form (1.0, 2.0, 3.0, ...) } /** * Returns a hashcode for the specified value. * * @return a hash code value for the specified value. */ public static final int hash(float value) { return Float.floatToIntBits(value*663608941.737f); // this avoids excessive hashCollisions in the case values are // of the form (1.0, 2.0, 3.0, ...) } /** * Returns a hashcode for the specified value. The hashcode is computed as ** using* 31^5*(d[0]*31^(n-1) + d[1]*31^(n-2) + ... + d[n-1]) * |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.