code: public static Collection intersection(final Collection a, final Collection b) {
          ArrayList list = new ArrayList();
          Map mapa = getCardinalityMap(a);
          Map mapb = getCardinalityMap(b);
          Set elts = new HashSet(a);
          elts.addAll(b);
          Iterator it = elts.iterator();
          while(it.hasNext()) {
              Object obj = it.next();
              for(int i=0,m=Math.min(getFreq(obj,mapa),getFreq(obj,mapb));i<m;i++) {
                  list.add(obj);
              }
          }
          return list;
      }
docs: Returns a {@link Collection} containing the intersection
  of the given {@link Collection}s.
  <p>
  The cardinality of each element in the returned {@link Collection}
  will be equal to the minimum of the cardinality of that element
  in the two given {@link Collection}s.
  
  @param a  the first collection, must not be null
  @param b  the second collection, must not be null
  @return the intersection of the two collections