Class DisjointSetsUnion<E>

java.lang.Object
org.bzdev.util.DisjointSetsUnion<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>

public class DisjointSetsUnion<E> extends Object implements Set<E>
Set implementation backed by a collection of disjoint sets. The set is immutable in that elements cannot be added explicitly - only the sets it backs can be modified . These sets must be disjoint for the iterator to not contain duplicate entries and for size() and hashCode() to return the correct values.
  • Constructor Details

    • DisjointSetsUnion

      public DisjointSetsUnion()
      Constructor.
    • DisjointSetsUnion

      public DisjointSetsUnion(Set<E> set1, Set<E> set2)
      Constructor for two sets. This is provided to avoid having to add sets for a common case.
      Parameters:
      set1 - the first set
      set2 - the second set
  • Method Details