souffle
2.0.2-371-g6315b36
|
Structure that emulates a Disjoint Set, i.e. More...
#include <UnionFind.h>
Public Member Functions | |
void | clear () |
Clears the DisjointSet of all nodes Invalidates all iterators. More... | |
DisjointSet ()=default | |
DisjointSet (DisjointSet &&other)=delete | |
DisjointSet (DisjointSet &other)=delete | |
parent_t | findNode (parent_t x) |
Equivalent to the find() function in union/find Find the highest ancestor of the provided node - flattening as we go. More... | |
std::atomic< block_t > & | get (parent_t node) const |
Yield reference to the node by its node index. More... | |
block_t | makeNode () |
Create a node with its parent as itself, rank 0. More... | |
DisjointSet & | operator= (DisjointSet &&ds)=delete |
DisjointSet & | operator= (DisjointSet &ds)=delete |
bool | sameSet (parent_t x, parent_t y) |
Check whether the two indices are in the same set. More... | |
size_t | size () |
Return the number of elements in this disjoint set (not the number of pairs) More... | |
void | unionNodes (parent_t x, parent_t y) |
Union the two specified index nodes. More... | |
Static Public Member Functions | |
static parent_t | b2p (const block_t inblock) |
Extract parent from block. More... | |
static rank_t | b2r (const block_t inblock) |
Extract rank from block. More... | |
static block_t | pr2b (const parent_t parent, const rank_t rank) |
Yield a block given parent and rank. More... | |
Private Member Functions | |
bool | updateRoot (const parent_t x, const rank_t oldrank, const parent_t y, const rank_t newrank) |
Update the root of the tree of which x is, to have y as the base instead. More... | |
Private Attributes | |
PiggyList< std::atomic< block_t > > | a_blocks |
Friends | |
template<typename TupleType > | |
class | EquivalenceRelation |
Structure that emulates a Disjoint Set, i.e.
a data structure that supports efficient union-find operations
Definition at line 54 of file UnionFind.h.
|
default |
|
delete |
|
delete |
Extract parent from block.
inblock | the block to be masked |
Definition at line 212 of file UnionFind.h.
References souffle::rank_mask.
Referenced by get().
Extract rank from block.
inblock | the block to be masked |
Definition at line 221 of file UnionFind.h.
References souffle::split_size.
|
inline |
Clears the DisjointSet of all nodes Invalidates all iterators.
Definition at line 140 of file UnionFind.h.
References findNode().
Referenced by souffle::SparseDisjointSet< value_type >::size().
Equivalent to the find() function in union/find Find the highest ancestor of the provided node - flattening as we go.
x | the node to find the parent of, whilst flattening its set-tree |
Definition at line 97 of file UnionFind.h.
Referenced by clear(), and souffle::test::TEST().
Yield reference to the node by its node index.
node | node to be searched |
Definition at line 86 of file UnionFind.h.
References b2p().
|
inline |
Create a node with its parent as itself, rank 0.
Definition at line 198 of file UnionFind.h.
Referenced by souffle::test::TEST().
|
delete |
|
delete |
Yield a block given parent and rank.
parent | the top half bits |
rank | the lower half bits |
Definition at line 231 of file UnionFind.h.
References b, and souffle::EqrelMapComparator< StorePair >::operator()().
Check whether the two indices are in the same set.
x | node to be checked |
y | node to be checked |
Definition at line 150 of file UnionFind.h.
|
inline |
Return the number of elements in this disjoint set (not the number of pairs)
Definition at line 76 of file UnionFind.h.
References a_blocks, and souffle::PiggyList< T >::get().
Referenced by souffle::test::TEST().
Union the two specified index nodes.
x | node to be unioned |
y | node to be unioned |
Definition at line 165 of file UnionFind.h.
Referenced by souffle::test::TEST().
|
inlineprivate |
Update the root of the tree of which x is, to have y as the base instead.
x | : old root |
oldrank | : old root rank |
y | : new root |
newrank | : new root rank |
Definition at line 123 of file UnionFind.h.
|
friend |
Definition at line 56 of file UnionFind.h.
Definition at line 58 of file UnionFind.h.
Referenced by size().