DisjointSet<T> class
A generic implementation of the Disjoint Set (Union-Find) data structure with path compression and union by rank optimization.
It works with any type T that can be compared using equality.
Constructors
Properties
Methods
-
add(
T item) → void - Adds a new element to the disjoint set.
-
find(
T item) → T -
Finds the representative (root) of the set that contains
item, applying path compression for efficiency. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
union(
T x, T y) → void -
Unites the sets containing
xandyusing union by rank.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited