template<class Idx = std::uint32_t>
class clustering::AtomicUnionFind< Idx >
Lock-free disjoint-set-union for concurrent edge folding.
Threads call unite concurrently with no external locking: a root is linked under another only through a compare-and-swap on its own parent slot, which can succeed only while it is still a root, so merges linearize. find applies path halving whose racing writes are benign – parent pointers only ever move toward a root.
Links are ordered by index: the larger root always attaches under the smaller, so once every unite has completed (and the callers have synchronized), the root of each component is exactly its minimum member. Flattened roots are therefore reproducible across runs regardless of thread interleaving.
- Template Parameters
-
| Idx | Unsigned integer index type; defaults to uint32_t. |
Definition at line 162 of file dsu.h.
template<class Idx = std::uint32_t>
Root of the component containing x at some point during the call.
Safe to run concurrently with unite; a concurrent merge may retarget the returned root, so quiescent callers (after a join) read the final component root while racing callers read a then-current one.
- Parameters
-
| x | Element index; must satisfy x < size(). |
- Returns
- Root index of
x's component.
Definition at line 183 of file dsu.h.