|
ADS
Algorithms and Data Structures
|
The union-find that many threads change at once, beyond the book [see UnionFind.h for the sequential ones]: the \( n \) elements \( 0 , \ldots , n - 1 \) in a forest of parents, a root being its own parent, each parent an atomic word changed only by compare-and-swap, with no lock. More...
#include "ADS/Contract.h"#include <atomic>#include <cstddef>#include <cstdint>#include <memory>#include <utility>Go to the source code of this file.
Classes | |
| class | ADS::ConcurrentUnionFind |
| the union-find of the elements \( [ 0 , n ) \) that threads change at once More... | |
Namespaces | |
| namespace | ADS |
The union-find that many threads change at once, beyond the book [see UnionFind.h for the sequential ones]: the \( n \) elements \( 0 , \ldots , n - 1 \) in a forest of parents, a root being its own parent, each parent an atomic word changed only by compare-and-swap, with no lock.
The operations are linearizable. On one thread, the linking by index with the splitting takes \( O( m \log_{2 + m / n} n ) \) steps for \( m \) operations on \( n \) elements (Tarjan and van Leeuwen); the randomized linking of Jayanti and Tarjan, which hooks by a random order instead of the indices, bounds the expected work on \( p \) threads by \( O( m ( \alpha( n , m / ( n p ) ) + \log( n p / m + 1 ) ) ) \), at the price of labels that are not the least elements.
The contracts [see Contract.h]: the elements are in \( [ 0 , n ) \), \( n < 2^{31} \); size() and the construction are not concurrent with the other operations.