SuperKoTable implements Serializable { public void add(long key) { if (key != EMPTY) { int slot = ((int) key & IGNORE_SIGN_BIT) % data.length; while (data[slot] != EMPTY) { if (data[slot] == key) { return; } slot = (slot + 1) % data.length; } data[slot] = key; } } SuperKoTable(CoordinateSystem coords); void add(long key); void clear(); boolean contains(long key); void copyDataFrom(SuperKoTable that); static final long EMPTY; static final int IGNORE_SIGN_BIT; }
@Test public void testAdd() { assertFalse(table.contains(-3)); table.add(-3); assertTrue(table.contains(-3)); assertFalse(table.contains(3)); table.add(3); assertTrue(table.contains(3)); table.add(3); assertTrue(table.contains(3)); }