SignedUnionFind with every orientation a sign ±1, kept in bytes: exact whenever every flip is ±1, as in the cubical dual, where a flip is a product of boundary coefficients ±1. The field never enters; the caller maps a sign to its field once, when it writes a representative. Integers map to any field by a ring homomorphism, so this gives the same coefficients as the field arithmetic, and none of its boxing.
def foreachMember(root: Int)(f: (Int, Int) =>Unit): Unit
f(member, sign relative to root) for every element merged (directly or not) into root, root included, in the order of SignedUnionFind.members. Exact for a root that is still a root, or was merged away.
f(member, sign relative to root) for every element merged (directly or not) into root, root included, in the order of SignedUnionFind.members. Exact for a root that is still a root, or was merged away.