com.koloboke.collect.impl.hash.DHash Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of koloboke-impl-common-jdk8 Show documentation
Show all versions of koloboke-impl-common-jdk8 Show documentation
Carefully designed and efficient extension of the Java Collections Framework with primitive specializations and more, built for Java 8 (Implementation Commons (for Implementation Library and Koloboke Compile))
The newest version!
/*
* Copyright 2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.koloboke.collect.impl.hash;
public interface DHash extends Hash {
class SeparateKVByteKeyMixing {
public static int mix(byte key) {
return key & Integer.MAX_VALUE;
}
}
class SeparateKVCharKeyMixing {
public static int mix(char key) {
return key;
}
}
class SeparateKVShortKeyMixing {
public static int mix(short key) {
return key & Integer.MAX_VALUE;
}
}
class SeparateKVIntKeyMixing {
public static int mix(int key) {
return key & Integer.MAX_VALUE;
}
}
class SeparateKVFloatKeyMixing {
public static int mix(int key) {
return key & Integer.MAX_VALUE;
}
}
class SeparateKVDoubleKeyMixing {
public static int mix(long key) {
// not to loose information about 31-32 and 63-64-th bits
long h = key ^ (key >> 40) ^ (key >> 24);
return ((int) h) & Integer.MAX_VALUE;
}
}
class SeparateKVLongKeyMixing {
public static int mix(long key) {
// not to loose information about 31-32 and 63-64-th bits
long h = key ^ (key >> 40) ^ (key >> 24);
return ((int) h) & Integer.MAX_VALUE;
}
}
class SeparateKVObjKeyMixing {
public static int mix(int hash) {
return hash & Integer.MAX_VALUE;
}
}
class ParallelKVByteKeyMixing {
public static int mix(byte key) {
return key & Integer.MAX_VALUE;
}
}
class ParallelKVCharKeyMixing {
public static int mix(char key) {
return key;
}
}
class ParallelKVShortKeyMixing {
public static int mix(short key) {
return key & Integer.MAX_VALUE;
}
}
class ParallelKVIntKeyMixing {
public static int mix(int key) {
return key & Integer.MAX_VALUE;
}
}
class ParallelKVFloatKeyMixing {
public static int mix(int key) {
return key & Integer.MAX_VALUE;
}
}
class ParallelKVDoubleKeyMixing {
public static int mix(long key) {
// not to loose information about 31-32 and 63-64-th bits
long h = key ^ (key >> 40) ^ (key >> 24);
return (((int) h) << 2) >>> 1;
}
}
class ParallelKVLongKeyMixing {
public static int mix(long key) {
// not to loose information about 31-32 and 63-64-th bits
long h = key ^ (key >> 40) ^ (key >> 24);
return (((int) h) << 2) >>> 1;
}
}
class ParallelKVObjKeyMixing {
public static int mix(int hash) {
return (hash << 2) >>> 1;
}
}
}