static int countIntersection(Set a, Set b) { if (a == null || b == null) ret 0; int n = 0; for (A x : b) if (a.contains(x)) ++n; ret n; }