lemon/unionfind.h
changeset 2544 5143b01bf1d5
parent 2506 216c6bd5c18c
child 2548 a3ba22ebccc6
equal deleted inserted replaced
15:7b5d50eb6de3 16:d4f8b15dd5fa
   690     /// given element.
   690     /// given element.
   691     int insert(const Item& item) {
   691     int insert(const Item& item) {
   692       int cdx = newClass();
   692       int cdx = newClass();
   693       classes[cdx].prev = -1;
   693       classes[cdx].prev = -1;
   694       classes[cdx].next = firstClass;
   694       classes[cdx].next = firstClass;
       
   695       if (firstClass != -1) {
       
   696 	classes[firstClass].prev = cdx;
       
   697       }
   695       firstClass = cdx;
   698       firstClass = cdx;
   696       
   699       
   697       int idx = newItem();
   700       int idx = newItem();
   698       items[idx].item = item;
   701       items[idx].item = item;
   699       items[idx].cls = cdx;
   702       items[idx].cls = cdx;