org.mapdb.Hasher Maven / Gradle / Ivy
The newest version!
package org.mapdb;
import java.util.Arrays;
/**
* Calculates hash from an object. It also provides `equals` method.
* Provides an alternative hashing method to {@link org.mapdb.HTreeMap}
*/
public interface Hasher {
int hashCode(K k);
boolean equals(K k1, K k2);
Hasher BASIC = new Hasher() {
@Override
public final int hashCode( Object k) {
return k.hashCode();
}
@Override
public boolean equals(Object k1, Object k2) {
return k1.equals(k2);
}
};
Hasher BYTE_ARRAY = new Hasher() {
@Override
public final int hashCode( byte[] k) {
return Arrays.hashCode(k);
}
@Override
public boolean equals(byte[] k1, byte[] k2) {
return Arrays.equals(k1,k2);
}
};
Hasher CHAR_ARRAY = new Hasher() {
@Override
public final int hashCode( char[] k) {
return Arrays.hashCode(k);
}
@Override
public boolean equals(char[] k1, char[] k2) {
return Arrays.equals(k1,k2);
}
};
Hasher INT_ARRAY = new Hasher() {
@Override
public final int hashCode( int[] k) {
return Arrays.hashCode(k);
}
@Override
public boolean equals(int[] k1, int[] k2) {
return Arrays.equals(k1,k2);
}
};
Hasher LONG_ARRAY = new Hasher() {
@Override
public final int hashCode( long[] k) {
return Arrays.hashCode(k);
}
@Override
public boolean equals(long[] k1, long[] k2) {
return Arrays.equals(k1,k2);
}
};
Hasher DOUBLE_ARRAY = new Hasher() {
@Override
public final int hashCode( double[] k) {
return Arrays.hashCode(k);
}
@Override
public boolean equals(double[] k1, double[] k2) {
return Arrays.equals(k1,k2);
}
};
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy