]> mj.ucw.cz Git - libucw.git/commitdiff
Heap: Revert changes to HEAP_DELETE, which broke position tracking
authorMartin Mares <mj@ucw.cz>
Tue, 30 Oct 2012 20:13:39 +0000 (21:13 +0100)
committerMartin Mares <mj@ucw.cz>
Tue, 30 Oct 2012 20:13:39 +0000 (21:13 +0100)
ucw/heap.h

index ec8f4f3a5fbc63f1ef21ef18720b285f7e8f3e15..ad560af4f5e4dc787c0890e86886e32e6a296db8 100644 (file)
  **/
 #define HEAP_DELETE(type,heap,num,less,swap,pos)                                       \
   do {                                                                                 \
+    uns _j, _l, _u;                                                                    \
+    type x;                                                                            \
+    _j = pos;                                                                          \
+    swap(heap,_j,num,x);                                                               \
     num--;                                                                             \
-    HEAP_REPLACE(type,heap,num,less,swap,pos,heap[num+1]);                             \
+    if (less(heap[_j], heap[num+1]))                                                   \
+      HEAP_BUBBLE_UP_J(heap,num,less,swap)                                             \
+    else                                                                               \
+      HEAP_BUBBLE_DOWN_J(heap,num,less,swap);                                          \
   } while(0)
 
 /**