annotate OrthancStone/Resources/Graveyard/RTStructTentativeReimplementation-BGO/DisjointDataSet.h @ 2177:4d21befb1501 default tip

clarify DICOMweb version check
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 23 Oct 2024 19:27:56 +0200
parents 16c01cc201e7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1005
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
1 /**
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
2 * Stone of Orthanc
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
2124
16c01cc201e7 updated copyright, as Osimis is not active on Orthanc anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2114
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
2114
c23eef785569 update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2077
diff changeset
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
1005
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
7 *
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
9 * modify it under the terms of the GNU Lesser General Public License
1005
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
11 * the License, or (at your option) any later version.
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
12 *
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
16 * Lesser General Public License for more details.
1005
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
17 *
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
19 * License along with this program. If not, see
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
20 * <http://www.gnu.org/licenses/>.
1005
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
21 **/
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
22
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
23 #pragma once
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
24
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
25 #include <vector>
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
26
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
27 #include "../StoneException.h"
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
28
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
29 namespace OrthancStone
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
30 {
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
31 class DisjointDataSet
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
32 {
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
33 public:
1018
58eed6bbcabb fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1005
diff changeset
34 DisjointDataSet(size_t itemCount) :
58eed6bbcabb fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1005
diff changeset
35 parents_(itemCount),
58eed6bbcabb fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1005
diff changeset
36 ranks_(itemCount)
1005
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
37 {
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
38 for (size_t index = 0; index < parents_.size(); index++)
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
39 {
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
40 SetParent(index,index);
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
41 ranks_[index] = 1;
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
42 }
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
43 }
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
44
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
45 size_t Find(size_t item)
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
46 {
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
47 /*
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
48 If parents_[i] == i, it means i is representative of a set.
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
49 Otherwise, we go up the tree...
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
50 */
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
51 if (GetParent(item) != item)
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
52 {
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
53 // if item is not a top item (representative of its set),
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54 // we use path compression to improve future lookups
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
55 // see: https://en.wikipedia.org/wiki/Disjoint-set_data_structure#Path_compression
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56 SetParent(item, Find(parents_[item]));
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57 }
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
59 // now that paths have been compressed, we are positively certain
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60 // that item's parent is a set ("X is a set" means that X is the
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
61 // representative of a set)
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
62 return GetParent(item);
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
63 }
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
65 /*
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
66 This merge the two sets that contains itemA and itemB
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
67 */
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
68 void Union(size_t itemA, size_t itemB)
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
69 {
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70 // Find current sets of x and y
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
71 size_t setA = Find(itemA);
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
72 size_t setB = Find(itemB);
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
74 // if setA == setB, it means they are already in the same set and
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 // do not need to be merged!
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
76 if (setA != setB)
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
77 {
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
78 // we need to merge the sets, which means that the trees representing
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
79 // the sets needs to be merged (there must be a single top parent to
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
80 // all the items originally belonging to setA and setB must be the same)
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
81
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
82 // since the algorithm speed is inversely proportional to the tree
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
83 // height (the rank), we need to combine trees in a way that
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
84 // minimizes this rank. See "Union by rank" at
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
85 // https://en.wikipedia.org/wiki/Disjoint-set_data_structure#by_rank
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
86 if (GetRank(setA) < GetRank(setB))
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
87 {
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
88 SetParent(setA, setB);
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
89 }
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
90 else if (GetRank(setA) > GetRank(setB))
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
91 {
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
92 SetParent(setB, setA);
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
93 }
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
94 else
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
95 {
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
96 SetParent(setB, setA);
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
97 BumpRank(setA);
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
98 // the trees had the same height but we attached the whole of setB
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
99 // under setA (under its parent), so the resulting tree is now
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
100 // 1 higher. setB is NOT representative of a set anymore.
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
101 }
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
102 }
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
103 }
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
104
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
105 private:
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
106 size_t GetRank(size_t i) const
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
107 {
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
108 ORTHANC_ASSERT(i < ranks_.size());
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
109 ORTHANC_ASSERT(ranks_.size() == parents_.size());
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
110 return ranks_[i];
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
111 }
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
112
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
113 size_t GetParent(size_t i) const
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
114 {
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
115 ORTHANC_ASSERT(i < parents_.size());
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
116 ORTHANC_ASSERT(ranks_.size() == parents_.size());
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
117 return parents_[i];
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
118 }
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
119
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
120 void SetParent(size_t i, size_t parent)
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
121 {
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
122 ORTHANC_ASSERT(i < parents_.size());
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
123 ORTHANC_ASSERT(ranks_.size() == parents_.size());
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
124 parents_[i] = parent;
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
125 }
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
126
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
127 void BumpRank(size_t i)
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
128 {
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
129 ORTHANC_ASSERT(i < ranks_.size());
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
130 ORTHANC_ASSERT(ranks_.size() == parents_.size());
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
131 ranks_[i] = ranks_[i] + 1u;
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
132 }
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
133
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
134 /*
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
135 This vector contains the direct parent of each item
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
136 */
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
137 std::vector<size_t> parents_;
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
138
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
139 /*
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
140 This vector contains the tree height of each set. The values in the
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
141 vector for non-representative items is UNDEFINED!
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
142 */
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
143 std::vector<size_t> ranks_;
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
144 };
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
145
7e861cfd142d Added a union find class (on integers) called DisjointDataSet
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
146 }