Search in sources :

Example 1 with LongHash

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

the class TestPerfectHash method testMinimal.

private int testMinimal(int size) {
    Random r = new Random(size);
    HashSet<Long> set = new HashSet<>(size);
    while (set.size() < size) {
        set.add((long) r.nextInt());
    }
    LongHash hf = new LongHash();
    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) LongHash(org.h2.dev.hash.MinimalPerfectHash.LongHash) HashSet(java.util.HashSet)

Aggregations

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