Currently trying to understand why this intersection method doesn't work properly, I think the problem is the if statement line but not sure if the problem solely lies there. I've included the necessary files to make my question clearer. The setIntersection method is part of the ArraySet class. The main method is in Hw8p2.
public SetADT<T> setIntersection (SetADT<T> set)
{
ArraySet<T> intersection = new ArraySet<T>();
for (int index=0; index < count; index++)
intersection.add(contents[index]);
Iterator<T> scan = set.iterator();
while (scan.hasNext()){
//if (!(intersection.contains(scan.next())))
if (intersection.contains(scan.next())==false)
intersection.remove(scan.next());
}
return intersection;