Example #1
0
  /**
   * 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);
      }
    }
  }
Example #2
0
 private boolean add(NestedSet<E> set) {
   return !set.isEmpty() && seenSets.add(set);
 }