/** * Transitively visit a nested set. * * @param nestedSet the nested set to visit transitively. */ @SuppressWarnings("unchecked") public void visit(NestedSet<E> nestedSet) { // This method suppresses the unchecked warning so that it can access the internal NestedSet // raw structure. Preconditions.checkArgument(nestedSet.getOrder() == Order.STABLE_ORDER); if (!visited.add(nestedSet)) { return; } for (NestedSet<E> subset : nestedSet.transitiveSets()) { visit(subset); } for (Object member : nestedSet.directMembers()) { if (visited.add((E) member)) { callback.accept((E) member); } } }
private boolean add(NestedSet<E> set) { return !set.isEmpty() && seenSets.add(set); }