static void removeAllBut(Set a, Collection b) { for (Iterator it = a.iterator(); it.hasNext(); ) if (!b.contains(it.next())) it.remove(); }