@Override public boolean retainAll(final Collection<?> c) { final Set<C> uniqueElementsToRemove = SetElements.difference(this, c); final boolean result = super.retainAll(uniqueElementsToRemove); if (result) { final Set<C> uniqueRemovedElements = SetElements.intersection(this, uniqueElementsToRemove); setChildrenParent(uniqueRemovedElements, null); } return result; }
@Override public boolean addAll(final int index, final Collection<? extends C> c) { final Set<? extends C> uniqueElementsToAdd = SetElements.difference(c, this); final boolean result = super.addAll(index, c); if (result) { final Set<C> uniqueAddedElements = SetElements.intersection(this, uniqueElementsToAdd); updateChildrenParent(uniqueAddedElements); } return result; }