public static ModifiableDBIDs intersection(DBIDs first,DBIDs second){
  if (first.size() > second.size()) {
    return intersection(second,first);
  }
  ModifiableDBIDs inter=newHashSet(first.size());
  for (DBIDIter it=first.iter(); it.valid(); it.advance()) {
    if (second.contains(it)) {
      inter.add(it);
    }
  }
  return inter;
}

public static ModifiableDBIDs intersection ( DBIDs first , DBIDs second ) { if ( first . size ( ) > second . size ( ) ) { return intersection ( second , first ) ; } ModifiableDBIDs inter = newHashSet ( first . size ( ) ) ; for ( DBIDIter it = first . iter ( ) ; it . valid ( ) ; it . advance ( ) ) { if ( second . contains ( it ) ) { inter . add ( it ) ; } } return inter ; }
compute the set intersection of two sets .
