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

DisjointSet()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sets Map<T, T>
Returns the current set representative for each element.
no setter

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 x and y using union by rank.

Operators

operator ==(Object other) bool
The equality operator.
inherited