![JAR search and dependency download from the Maven repository](/logo.png)
net.sf.javagimmicks.collections.CollectionDifference Maven / Gradle / Ivy
package net.sf.javagimmicks.collections;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class CollectionDifference
{
protected final List _onlyA = new ArrayList();
protected final List _onlyB = new ArrayList();
protected final List _both = new ArrayList();
public CollectionDifference(Collection extends E> a, Collection extends E> b)
{
for(E element : a)
{
if(b.contains(element))
{
_both.add(element);
}
else
{
_onlyA.add(element);
}
}
for(E element : b)
{
if(!_both.contains(element))
{
_onlyB.add(element);
}
}
}
public List getOnlyA()
{
return _onlyA;
}
public List getOnlyB()
{
return _onlyB;
}
public List getBoth()
{
return _both;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy