disjoint_set.go
func Union(forests *Forests, ds1, ds2 *DisjointSet) {
	newDS := &DisjointSet{}
	newDS.represent = ds1.represent
	newDS.members = ds1.members
	for k := range ds2.members {
		newDS.members[k] = struct{}{}
	}
	forests.mu.Lock()
	defer forests.mu.Unlock()
	forests.data[newDS] = struct{}{}
	delete(forests.data, ds1)
	delete(forests.data, ds2)
}
func Union(forests *Forests, ds1, ds2 *DisjointSet) {
	newDS := &DisjointSet{}
	newDS.represent = ds1.represent
	newDS.members = ds1.members
	for k := range ds2.members {
		newDS.members[k] = struct{}{}
	}
	forests.mu.Lock()
	defer forests.mu.Unlock()
	forests.data[newDS] = struct{}{}
	delete(forests.data, ds1)
	delete(forests.data, ds2)
}
func Union ( forests * Forests , ds1 , ds2 * DisjointSet ) { newDS := & DisjointSet { } newDS . represent = ds1 . represent newDS . members = ds1 . members for k := range ds2 . members { newDS . members [ k ] = struct { } { } } forests . mu . Lock ( ) defer forests . mu . Unlock ( ) forests . data [ newDS ] = struct { } { } delete ( forests . data , ds1 ) delete ( forests . data , ds2 ) }
// Union unions two DisjointSet, with ds1's represent.
Union unions two DisjointSet with ds1 s represent .