MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / setUnion

Function setUnion

src/backend/cpu/kernel/regions.hpp:54–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52
53template<typename T>
54static void setUnion(LabelNode<T>* x, LabelNode<T>* y) {
55 LabelNode<T>* xRoot = find(x);
56 LabelNode<T>* yRoot = find(y);
57 if (xRoot == yRoot) return;
58
59 T xMinLabel = xRoot->getMinLabel();
60 T yMinLabel = yRoot->getMinLabel();
61 xRoot->setMinLabel(std::min(xMinLabel, yMinLabel));
62 yRoot->setMinLabel(std::min(xMinLabel, yMinLabel));
63
64 if (xRoot->getRank() < yRoot->getRank())
65 xRoot->setParent(yRoot);
66 else if (xRoot->getRank() > yRoot->getRank())
67 yRoot->setParent(xRoot);
68 else {
69 yRoot->setParent(xRoot);
70 xRoot->setRank(xRoot->getRank() + 1);
71 }
72}
73
74template<typename T>
75void regions(Param<T> out, CParam<char> in, af_connectivity connectivity) {

Callers 1

regionsFunction · 0.70

Calls 7

findFunction · 0.85
getMinLabelMethod · 0.80
setMinLabelMethod · 0.80
getRankMethod · 0.80
setParentMethod · 0.80
setRankMethod · 0.80
minFunction · 0.50

Tested by

no test coverage detected