20 #ifndef GALOIS_UNIONFIND_H
21 #define GALOIS_UNIONFIND_H
25 #include "galois/config.h"
39 while (rep->m_component != rep) {
40 T* next = rep->m_component.load(std::memory_order_relaxed);
55 return m_component.load(std::memory_order_relaxed) ==
this;
58 T*
get()
const {
return m_component.load(std::memory_order_relaxed); }
60 const T*
find()
const {
return findImpl(); }
62 T*
find() {
return findImpl(); }
74 while (rep->m_component.load(std::memory_order_relaxed) != rep) {
76 T* next = rep->m_component.load(std::memory_order_relaxed);
94 while (rep->m_component.load(std::memory_order_relaxed) != rep) {
95 T* next = rep->m_component.load(std::memory_order_relaxed);
97 if (prev && prev->m_component.load(std::memory_order_relaxed) == rep) {
98 prev->m_component.store(next, std::memory_order_relaxed);
109 T* a =
m_component.load(std::memory_order_relaxed);
111 a = a->findAndCompress();
112 b = b->findAndCompress();
118 if (a->m_component.compare_exchange_strong(a, b)) {
Intrusive union-find implementation.
Definition: UnionFind.h:33
T * findAndCompress()
Definition: UnionFind.h:84
UnionFindNode(T *s)
Definition: UnionFind.h:49
UnionFindNode< T > SuperTy
Definition: UnionFind.h:52
T * merge(T *b)
Lock-free merge. Returns if merge was done.
Definition: UnionFind.h:108
const T * find() const
Definition: UnionFind.h:60
T * find()
Definition: UnionFind.h:62
void compress()
Compress ONLY node to point directly to the root of the tree; nodes on path are not altered...
Definition: UnionFind.h:66
std::atomic< T * > m_component
Definition: UnionFind.h:47
bool isRep() const
Definition: UnionFind.h:54