2 * Sherlock Library -- Universal Heap Macros
4 * (c) 2001 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
10 #define HEAP_BUBBLE_DOWN_J(heap,num,less,swap) \
16 if (less(heap[j],heap[l]) && (l == num || less(heap[j],heap[l+1]))) \
18 if (l != num && less(heap[l+1],heap[l])) \
24 #define HEAP_BUBBLE_UP_J(heap,num,less,swap) \
28 if (less(heap[u], heap[j])) \
34 #define HEAP_INIT(type,heap,num,less,swap) \
42 HEAP_BUBBLE_DOWN_J(heap,num,less,swap) \
47 #define HEAP_DELMIN(type,heap,num,less,swap) \
54 HEAP_BUBBLE_DOWN_J(heap,num,less,swap); \
57 #define HEAP_INSERT(type,heap,num,less,swap) \
62 HEAP_BUBBLE_UP_J(heap,num,less,swap); \
65 #define HEAP_INCREASE(type,heap,num,less,swap) \
70 HEAP_BUBBLE_DOWN_J(heap,num,less,swap); \
73 #define HEAP_DELETE(type,heap,num,less,swap,pos) \
80 if (less(heap[j], heap[num+1])) \
81 HEAP_BUBBLE_UP_J(heap,num,less,swap) \
83 HEAP_BUBBLE_DOWN_J(heap,num,less,swap); \