src/work/johanna/unionfind.h
changeset 382 f177fc597abd
parent 218 5964f1c64ca1
child 394 3a34c5626e52
equal deleted inserted replaced
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;