public synchronized int markRecentAsFoundInBitSet(long[] uids, BitSet found, int bitSetLength) { if (found.length() == 0) { return 0; } int ret = 0; int index = 0; while (true) { if (index < 0 || index >= bitSetLength) { break; } index = found.nextClearBit(index); if (index < 0 || index >= bitSetLength) { break; } if (elems.contains(uids[index])) { found.set(index); ret++; } else { } index++; } return ret; }