changeset 349 | 42c660f58702 |
parent 218 | 5964f1c64ca1 |
child 394 | 3a34c5626e52 |
1:309ebe8161e5 | 2:a361efe2190f |
---|---|
22 UnionFind(TIntMap& m) : map(m) {} |
22 UnionFind(TIntMap& m) : map(m) {} |
23 |
23 |
24 |
24 |
25 int whichComponent(T a) |
25 int whichComponent(T a) |
26 { |
26 { |
27 int comp0 = map.get(a); |
27 int comp0 = map[a]; |
28 if (comp0 < 0) { |
28 if (comp0 < 0) { |
29 return insertNewElement(a); |
29 return insertNewElement(a); |
30 } |
30 } |
31 int comp = comp0; |
31 int comp = comp0; |
32 int next; |
32 int next; |