package common;

import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * <p>A utility class providing certain set-manipulation tools, in the form of instance methods,
 * that some sets used in the sudoku target-solving techniques provided in this package.</p>
 * @author fiveham
 * @author fiveham
 *
 * @param <T>
 * @param <T>@param <T>
 */
public class ToolSet<T> extends HashSet<T> {
	
	private static final long serialVersionUID = 7562530465837262993L;
	
  /**
   * <p>Constructs an empty ToolSet.</p>
   */
	protected ToolSet() {
	}
	
  /**
   * <p>Constructs a ToolSet containing all the elements of {@code c}.</p>
   * @param c the collection whose elements will be contained by this ToolSet
   */
	private ToolSet(Collection<? extends T> c) {
		super(c);
	}
	
  /**
   * <p>Constructs an empty ToolSet whose capacity is initially set to {@code initialCapacity}.</p>
   * @param initialCapacity the initial capacity of this ToolSet
   */
	protected ToolSet(int initialCapacity) {
		super(initialCapacity);
	}
	
    /**
     * <p>Returns true if this set intersects the {@code otherSet}, false otherwise.</p>
     * @param otherSet another set
     * @return true if this set intersects the {@code otherSet}, false otherwise
     */
	public boolean intersects(Collection<? extends T> otherSet){
		return !Collections.disjoint(this, otherSet);
	}
	
	public ToolSet<T> intersection(Collection<? extends T> otherSet){
		ToolSet<T> result = new ToolSet<>(this);
		result.retainAll(otherSet);
		return result;
	}
	
    /**
     * <p>Returns a list of elements from this set not found in {@code otherCollection}.</p>
     * @param otherCollection
     * @return
     */
	public List<T> complement(Collection<T> otherCollection){
		return stream().filter((e)->!otherCollection.contains(e)).collect(Collectors.toList());
	}
	
    /**
     * <p>Returns true if {@code otherSet} is a proper subset of {@code this}, false otherwise.</p>
     * @param otherSet another set
     * @return true if {@code otherSet} is a proper subset of {@code this}, false otherwise
     */
	public boolean hasProperSubset(Set<T> otherSet){
		return size() > otherSet.size() && containsAll(otherSet);
	}
	
    /**
     * <p>Returns true if {@code otherSet} is a subset of {@code this}, false otherwise.</p>
     * @param otherSet another set
     * @return true if {@code otherSet} is a proper subset of {@code this}, false otherwise
     */
	public boolean hasSubset(Set<T> otherSet){
		return size() >= otherSet.size() && containsAll(otherSet);
	}
}

@@ -43,38 +43,8 @@
 on;%0A
-import java.util.Collections;%0A
 impo
@@ -1104,344 +1104,8 @@
 %7D%0A%09%0A
-    /**%0A     * %3Cp%3EReturns true if this set intersects the %7B@code otherSet%7D, false otherwise.%3C/p%3E%0A     * @param otherSet another set%0A     * @return true if this set intersects the %7B@code otherSet%7D, false otherwise%0A     */%0A%09public boolean intersects(Collection%3C? extends T%3E otherSet)%7B%0A%09%09return !Collections.disjoint(this, otherSet);%0A%09%7D%0A%09%0A
 %09pub

remove unused method intersects()