Find the representing element for d
.
Find the representing element for d
. Two
elements belong to the same set iff they have the same
representative.
Check whether an element is already present in the forest.
Iterator over all elements of this forest.
Add a new element to the forest.
Add a new element to the forest; the operation has no effect if the element is already present in the forest.
Join two sets.
A simple, textbook implementation of a union-find data structure.