public void executeDiff(final Iterable<T> coll, final boolean saveAsLastState, final Consumer<T> addedConsumer, final Consumer<K> removedConsumer) {

        //We need to remember the last state keys NOT inside 'coll'.
        final Set<K> notDisplayed = new HashSet<>(lastState.keySet());

        for (T element : coll) {
            final K key = keyMapper.apply(element);
            final V value = valueMapper == null ? null : valueMapper.apply(element, key);
            notDisplayed.remove(key);

            if (!lastState.containsKey(key) || !Objects.equals(lastState.get(key), value)) {
                addedConsumer.accept(element);
                if (saveAsLastState) {
                    lastState.put(key, value);
                }
            }
        }

        for (K ndKey : notDisplayed) {
            removedConsumer.accept(ndKey);
            if (saveAsLastState) {
                lastState.remove(ndKey);
            }
        }

    }
#
Compares the given collection to the existing last state in this class.
Calls the add/remove-consumers for every added/removed element.
Optionally (via parameter 'saveAsLastState') the given collection is made the last state, e.g. next call to executeDiff will perform diff against this coll.
main/src/main/java/cgeo/geocaching/utils/CollectionDiff.java