diff options
author | Erich Schubert <erich@debian.org> | 2013-10-29 20:02:37 +0100 |
---|---|---|
committer | Andrej Shadura <andrewsh@debian.org> | 2019-03-09 22:30:37 +0000 |
commit | ec7f409f6e795bbcc6f3c005687954e9475c600c (patch) | |
tree | fbf36c0ab791c556198b487ca40ae56ae5ab1ee5 /src/de/lmu/ifi/dbs/elki/utilities/Util.java | |
parent | 974d4cf6d54cadc06258039f2cd0515cc34aeac6 (diff) | |
parent | 8300861dc4c62c5567a4e654976072f854217544 (diff) |
Import Debian changes 0.6.0~beta2-1
elki (0.6.0~beta2-1) unstable; urgency=low
* New upstream beta release.
* 3DPC extension is not yet included.
Diffstat (limited to 'src/de/lmu/ifi/dbs/elki/utilities/Util.java')
-rw-r--r-- | src/de/lmu/ifi/dbs/elki/utilities/Util.java | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/src/de/lmu/ifi/dbs/elki/utilities/Util.java b/src/de/lmu/ifi/dbs/elki/utilities/Util.java index 42144958..439ef171 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/Util.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/Util.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.utilities; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2012 + Copyright (C) 2013 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team @@ -23,12 +23,10 @@ package de.lmu.ifi.dbs.elki.utilities; along with this program. If not, see <http://www.gnu.org/licenses/>. */ - import java.util.BitSet; import java.util.Comparator; import java.util.Random; - /** * This class collects various static helper methods. * @@ -39,6 +37,11 @@ import java.util.Random; */ public final class Util { /** + * Prime number used in hash code computation. + */ + private static final long HASHPRIME = 2654435761L; + + /** * Fake constructor: do not instantiate. */ private Util() { @@ -77,21 +80,55 @@ public final class Util { /** * Mix multiple hashcodes into one. * + * @param hash Single Hashcodes to "mix" + * @return Original hash code + */ + @Deprecated + public static int mixHashCodes(int hash) { + return hash; + } + + /** + * Mix multiple hashcodes into one. + * + * @param hash1 First hashcode to mix + * @param hash2 Second hashcode to mix + * @return Mixed hash code + */ + public static int mixHashCodes(int hash1, int hash2) { + return (int) (hash1 * HASHPRIME + hash2); + } + + /** + * Mix multiple hashcodes into one. + * + * @param hash1 First hashcode to mix + * @param hash2 Second hashcode to mix + * @param hash3 Third hashcode to mix + * @return Mixed hash code + */ + public static int mixHashCodes(int hash1, int hash2, int hash3) { + long result = hash1 * HASHPRIME + hash2; + return (int) (result * HASHPRIME + hash3); + } + + /** + * Mix multiple hashcodes into one. + * * @param hash Hashcodes to mix * @return Mixed hash code */ public static int mixHashCodes(int... hash) { - final long prime = 2654435761L; if (hash.length == 0) { return 0; } long result = hash[0]; for (int i = 1; i < hash.length; i++) { - result = result * prime + hash[i]; + result = result * HASHPRIME + hash[i]; } return (int) result; } - + /** * Static instance. */ |