lemon/fourary_heap.h
changeset 752 39a5b48bcace
parent 750 bb3392fe91f2
child 753 9314d9339475
     1.1 --- a/lemon/fourary_heap.h	Fri Jul 10 09:15:22 2009 +0200
     1.2 +++ b/lemon/fourary_heap.h	Fri Jul 10 09:17:13 2009 +0200
     1.3 @@ -165,14 +165,16 @@
     1.4      }
     1.5  
     1.6      void bubbleDown(int hole, Pair p, int length) {
     1.7 -      int child = firstChild(hole);
     1.8 -      while( child<length && length>1 ) {
     1.9 -        child = findMin(child,length);
    1.10 -        if( !less(_data[child], p) )
    1.11 -          goto ok;
    1.12 -        move(_data[child], hole);
    1.13 -        hole = child;
    1.14 -        child = firstChild(hole);
    1.15 +      if( length>1 ) {
    1.16 +        int child = firstChild(hole);
    1.17 +        while( child<length ) {
    1.18 +          child = findMin(child, length);
    1.19 +          if( !less(_data[child], p) )
    1.20 +            goto ok;
    1.21 +          move(_data[child], hole);
    1.22 +          hole = child;
    1.23 +          child = firstChild(hole);
    1.24 +        }
    1.25        }
    1.26      ok:
    1.27        move(p, hole);