llir-opt  0.0.1
Low-Level Post-Link Optimiser for OCaml and C
union_find.h
1 // This file if part of the llir-opt project.
2 // Licensing information can be found in the LICENSE file.
3 // (C) 2018 Nandor Licker. All rights reserved.
4 
5 #pragma once
6 
7 #include <cstdint>
8 #include <vector>
9 
10 
11 
15 class UnionFind {
16 public:
18  UnionFind(unsigned n);
19 
21  void Union(unsigned a, unsigned b);
22 
24  unsigned Find(unsigned node);
25 
26 private:
28  struct Node {
30  unsigned Parent;
32  unsigned Class;
34  unsigned Rank;
35  };
36 
38  unsigned FindNode(unsigned node);
39 
41  std::vector<Node> nodes_;
42 };
Node
Definition: node.h:43
UnionFind
Definition: union_find.h:18