core :: DisjointSet :: from
# Copy constructor
init from(other: DisjointSet[E])
do
# Associate a root node in other to the associated root node in self
var map = new HashMap[DisjointSetNode, DisjointSetNode]
for e, v in other.nodes do
# Create the associated node
var n2 = new DisjointSetNode
nodes[e] = n2
# Get the root node in other and the associated one in self
var p = other.find(e)
var p2 = map.get_or_null(p)
if p2 == null then
# if no associated root node, then a new subset is created
map[p] = n2.parent
number_of_subsets += 1
else
# else attach the new node to the subset of the root node
n2.parent = p2
end
end
end
lib/core/collection/union_find.nit:42,2--64,4