private int hash(String key) {
        int klen = key.length();
        int out = klen;
        if (select == null) {
            for (int i = 0; i < klen; i++) {
                int c = key.charAt(i) - min;
                if (c < 0) return -1;
                if (c >= kvals.length) return -2;
                out += kvals[c];
            }

        } else {
            for (int i : select) {
                if (i >= klen) continue;
                int c = key.charAt(i) - min;
                if (c < 0) return -1;
                if (c >= kvals.length) return -2;
                out += kvals[c];
            }
        }

        return out;
    }
@Test
    public void testHash() {
        System.out.println("PerfectHash");
        PerfectHash hash = new PerfectHash("abc", "great", "hash");
        assertEquals(0, hash.get("abc"));
        assertEquals(1, hash.get("great"));
        assertEquals(2, hash.get("hash"));
        assertEquals(-1, hash.get("perfect"));
        assertEquals(-1, hash.get("hash2"));
    }