lib-manipulation/src/main/java/com/nhaarman/listviewanimations/itemmanipulation/swipedismiss/undo/Util.java
@NonNull
    static Collection<Integer> processDeletions(@NonNull final Collection<Integer> positions, @NonNull final List<Integer> dismissedPositions) {
        Collection<Integer> result = new ArrayList<>(positions);
        Collections.sort(dismissedPositions, Collections.reverseOrder());
        Collection<Integer> newUndoPositions = new ArrayList<>();
        for (int position : dismissedPositions) {
            for (Iterator<Integer> iterator = result.iterator(); iterator.hasNext(); ) {
                int undoPosition = iterator.next();
                if (undoPosition > position) {
                    iterator.remove();
                    newUndoPositions.add(undoPosition - 1);
                } else if (undoPosition == position) {
                    iterator.remove();
                } else {
                    newUndoPositions.add(undoPosition);
                }
            }
            result.clear();
            result.addAll(newUndoPositions);
            newUndoPositions.clear();
        }

        return result;
    }
@NonNull
    static Collection<Integer> processDeletions(@NonNull final Collection<Integer> positions, @NonNull final List<Integer> dismissedPositions) {
        Collection<Integer> result = new ArrayList<>(positions);
        Collections.sort(dismissedPositions, Collections.reverseOrder());
        Collection<Integer> newUndoPositions = new ArrayList<>();
        for (int position : dismissedPositions) {
            for (Iterator<Integer> iterator = result.iterator(); iterator.hasNext(); ) {
                int undoPosition = iterator.next();
                if (undoPosition > position) {
                    iterator.remove();
                    newUndoPositions.add(undoPosition - 1);
                } else if (undoPosition == position) {
                    iterator.remove();
                } else {
                    newUndoPositions.add(undoPosition);
                }
            }
            result.clear();
            result.addAll(newUndoPositions);
            newUndoPositions.clear();
        }

        return result;
    }
@ NonNull static Collection < Integer > processDeletions ( @ NonNull final Collection < Integer > positions , @ NonNull final List < Integer > dismissedPositions ) { Collection < Integer > result = new ArrayList <> ( positions ) ; Collections . sort ( dismissedPositions , Collections . reverseOrder ( ) ) ; Collection < Integer > newUndoPositions = new ArrayList <> ( ) ; for ( int position : dismissedPositions ) { for ( Iterator < Integer > iterator = result . iterator ( ) ; iterator . hasNext ( ) ; ) { int undoPosition = iterator . next ( ) ; if ( undoPosition > position ) { iterator . remove ( ) ; newUndoPositions . add ( undoPosition - 1 ) ; } else if ( undoPosition == position ) { iterator . remove ( ) ; } else { newUndoPositions . add ( undoPosition ) ; } } result . clear ( ) ; result . addAll ( newUndoPositions ) ; newUndoPositions . clear ( ) ; } return result ; }
Removes positions in {@code dismissedPositions} from {@code positions}, and shifts the remaining positions accordingly.

@param positions          the list of positions to remove from.
@param dismissedPositions the list of positions to remove.

@return a new {@link java.util.Collection} instance, containing the resulting positions.
Removes positions in { @code dismissedPositions } from { @code positions } and shifts the remaining positions accordingly .