// returns true if any changes static bool removeAllBut(Set a, Collection b) { bool changes; b = asSet(b); if (a != null) for (Iterator it = a.iterator(); it.hasNext(); ) if (!contains(b, it.next())) { it.remove(); set changes; } ret changes; } static bool removeAllBut(Map a, Collection b) { ret a != null && removeAllBut(a.keySet(), b); }