MemberHolder { public void visit(int listId, MemberHolderVisitor visitor) { ByteBuffer buff = data[listId]; ((Buffer)buff).flip(); while (buff.hasRemaining()) { visitor.visit(VarLenLong.readLongSigned(buff)); } visitor.finished(); ((Buffer)buff).limit(buff.capacity()); } MemberHolder(int maxSets);  MemberHolder(int maxLists, int initBytesPerSet); void addMember(int listId, long member); boolean removeMember(int listId, long member); boolean isEmpty(int listId); int containsCount(int listId, long member); void visit(int listId, MemberHolderVisitor visitor);  }
@Test public void testAddMembers() { MemberHolder holder = new MemberHolder(10); final int listId = 3; final int seed = 42; Random r = new Random(seed); populate(holder, listId, r); final Random expectedR = new Random(seed); holder.visit(listId, new MemberHolderVisitor() { int i = 0; @Override public void visit(long value) { if (++i<100000) { assertEquals(expectedR.nextInt(i), value); } else { long lng = expectedR.nextLong() & 0x7FFFFFFFFFFFFFFFl; if (lng!=value) { System.out.println("expected:"+Long.toBinaryString(lng)); System.out.println(" found:"+Long.toBinaryString(value)); } assertEquals(lng, value); } } @Override public void finished() { } }); }