@Override
  public boolean retainAll(@NotNull final Collection<?> c) {
    boolean removed = false;
    HashSet<?> hashed = new HashSet<>(c);
    Iterator<V> iter = delegate.iterator();
    while (iter.hasNext()) {
      V v = iter.next();
      if (!hashed.contains(v)) {
        removed = true;
        undoLog.add(UndoEntry.remove(v));
        iter.remove();
      }
    }
    return removed;
  }
Create an UndoSet backed by another Set instance.

@param delegate The Set instance to use for backing storage
@param <V> The type of the collection.
@return an unduable set
evm/src/main/java/org/hyperledger/besu/collections/undo/UndoSet.java