X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fheap.h;h=8404858e6a516d9f318e340c7b324012d7003545;hb=b42162f5526360acc6930e3d2e296af1fef08e63;hp=268cc2572cd8d3ad855464d7c8a6e2a5b41dead7;hpb=dd1d31f3e9b115b3e5a35d18243880ebc41990f2;p=libucw.git diff --git a/lib/heap.h b/lib/heap.h index 268cc257..8404858e 100644 --- a/lib/heap.h +++ b/lib/heap.h @@ -2,6 +2,9 @@ * Sherlock Library -- Universal Heap Macros * * (c) 2001 Martin Mares + * + * This software may be freely distributed and used according to the terms + * of the GNU Lesser General Public License. */ #define HEAP_BUBBLE_DOWN_J(heap,num,less,swap) \ @@ -71,11 +74,14 @@ do { \ uns j, l, u; \ type x; \ - swap(heap,pos,num,x); \ - num--; \ j = pos; \ + swap(heap,j,num,x); \ + num--; \ 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) + +/* Default swapping macro */ +#define HEAP_SWAP(heap,a,b,t) (t=heap[a], heap[a]=heap[b], heap[b]=t)