uf_union(9)
π uf_union β the "let's be friends" function π
okay so quick vibe check: this is uf_union(9) from the Kernel API Manual, and no cap it's one of the most useful little functions in the whole kernel friend group. it's literally a matchmaker for sets π«Ά
β¨ NAME β¨
uf_union β merge two sets, using union by rank π
π SYNOPSIS π
void uf_union (struct uf_node *node1 , struct uf_node *node2 );
πΈ ARGUMENTS πΈ
node1β the first node π₯node2β the second node π₯
like, they're just two nodes, bestie. two little guys about to become one big friend group.
π¦ DESCRIPTION π¦
okay so here's the tea β: this function merges the sets containing node1 and node2, by comparing the ranks to keep the tree balanced.
that's it. that's the whole thing. it literally does a rank comparison so the tree doesn't turn into a sad little stick, and then boom π₯ β the two sets are one set now. main character energy for ur disjoint-set forest, fr fr. balance is the vibe check and this function passes it every time π
π SEE ALSO π
- Kernel file
./lib/union_find.c uf_find(9)
that's the whole page, bestie β go union some sets and slay β¨
signing off with love from the ./lib girlies, October 2026 ππ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms