I have a logical string (for example, "01100..001") 128 characters long (meaning 128 is the number 0/1). I am looking for an efficient (fast) hash function in Java that provides a much smaller representation than 128 bits and, obviously, with fewer collisions. Can someone help me if there is such a hash function? Any suggestion?
Try using the method .hashCode()in a Java class String, it returns int, and it is very fast.
.hashCode()
String
int
Or you can use the method .hashCode()on java.util.BitSet, as Pulsar suggests, if you prefer to store your data in BitSet.
java.util.BitSet
BitSet
, java.util.BitSet, , , ? http://docs.oracle.com/javase/6/docs/api/java/util/BitSet.html .hashCode().
, hashCode() String. .
hashCode()
, OpenJDK String hashCode() hash .
hash
, 128 128 ? , hashCode() Java, int, ints Java 32-.