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

GENERIC: equate ( a b disjoint-set -- )


Methods

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 ;