All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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 a, Collection 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