equate ( a b disjoint-set -- )
Factor handbook » The language » Collections » Disjoint sets

Prev:add-atom ( a disjoint-set -- )

Vocabulary
disjoint-sets

Inputs
aan object
ban object
disjoint-seta disjoint-set
Outputs
None

Word description
Merges the equivalence classes of two elements, which must previously have been added with add-atom.

Definition
IN: disjoint-sets
GENERIC: equate ( a b disjoint-set -- )
Methods
USING: disjoint-sets disjoint-sets.private kernel ;
M:: disjoint-set equate ( a b disjoint-set -- )
a b disjoint-set representatives 2dup =
[ 2drop ] [
2dup disjoint-set ranks
[ swap ] [ over disjoint-set inc-rank ] [ ] branch
disjoint-set link-sets
] if ;