Search in sources :

Example 1 with StringHash

use of org.h2.dev.hash.MinimalPerfectHash.StringHash in project h2database by h2database.

the class TestPerfectHash method testMinimalWithString.

private int testMinimalWithString(int size) {
    Random r = new Random(size);
    HashSet<String> set = new HashSet<>(size);
    while (set.size() < size) {
        set.add("x " + r.nextDouble());
    }
    StringHash hf = new StringHash();
    byte[] desc = MinimalPerfectHash.generate(set, hf);
    int max = testMinimal(desc, set, hf);
    assertEquals(size - 1, max);
    return desc.length * 8;
}
Also used : Random(java.util.Random) StringHash(org.h2.dev.hash.MinimalPerfectHash.StringHash) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 Random (java.util.Random)1 StringHash (org.h2.dev.hash.MinimalPerfectHash.StringHash)1