package common;

import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;

/**
 * <p>A TestIterator meant for exploring a space of combinations. As such, removing elements from
 * the backing collection should have an effect on subsequent results from next(). This class
 * provides convenience methods for excluding certain elements of the backing collection from
 * combinations returned from next().</p>
 * @author fiveham
 * @author fiveham
 *
 * @param <T>
 * @param <T>@param <T>
 */
public class IsoIterator<T> extends TestIterator<List<T>> {
	
	protected final Set<T> exclude;
  
    /**
     * <p>Constructs an IsoIterator wrapping the specified Iterator and having no tests.</p>
     * @param wrappedIterator the Iterator that supplies this IsoIterator with elements to test and
     * contingently reduce
     */
	public IsoIterator(Iterator<List<T>> wrappedIterator) {
		super(wrappedIterator);
		this.exclude = new HashSet<>();
		addTest(genExcludeTest(exclude));
	}
	
	public static <T> Predicate<List<T>> genExcludeTest(Set<T> exclude){
		return (list) -> Collections.disjoint(list, exclude);
	}
	
    /**
     * <p>Prevents {@code item} from appearing in any combinations produced by subsequent calls to
     * next().</p>
     * @param item an element of the backing collection from which elements are drawn to construct
     * combinations
     * @return true if the population of excluded items was changed by this method call, false
     * otherwise
     */
	public boolean exclude(T item){
		return exclude.add(item);
	}
}

@@ -1216,437 +1216,6 @@
 %0A%09%7D%0A
-%09%0A    /**%0A     * %3Cp%3EPrevents %7B@code item%7D from appearing in any combinations produced by subsequent calls to%0A     * next().%3C/p%3E%0A     * @param item an element of the backing collection from which elements are drawn to construct%0A     * combinations%0A     * @return true if the population of excluded items was changed by this method call, false%0A     * otherwise%0A     */%0A%09public boolean exclude(T item)%7B%0A%09%09return exclude.add(item);%0A%09%7D%0A
 %7D%0A

remove unused exclude() method