@Override
public void submit(TIntSet removed, TIntSet added) {
insureInitialized();
TIntSet parentRemoved = null, parentAdded;
//Calculating really removed indices set
TIntIterator iterator = removed.iterator();
int iIndex, index;
while (iterator.hasNext()) {
iIndex = Arrays.binarySearch(allDummyIndices, index = iterator.next());
usedArrays[iIndex].clear(position.currentIndex());
if (usedArrays[iIndex].bitCount() == 0) {
if (parentRemoved == null)
parentRemoved = new TIntHashSet(removed.size());
parentRemoved.add(index);
}
}
if (parentRemoved == null)
parentRemoved = EMPTY_INT_SET;
//Processing added indices and calculating added set to
//propagate to position.
parentAdded = new TIntHashSet(added);
iterator = parentAdded.iterator();
while (iterator.hasNext()) {
//Searching index in initial dummy indices set
iIndex = Arrays.binarySearch(allDummyIndices, iterator.next());
//If this index is new for this sum it will never be removed,
//so we don't need to store information about it.
if (iIndex < 0)
continue;
//If this index was already somewhere in the sum,
//we don't have to propagate it to position
if (!usedArrays[iIndex].isEmpty())
iterator.remove();
//Marking this index as added to current summand
usedArrays[iIndex].set(position.currentIndex());
}