Lines Matching defs:i
44 * element of the heap array is not used; i.e. heap subscripts are 1-based,
47 #define heap_parent(i) ((i) >> 1)
48 #define heap_left(i) ((i) << 1)
106 float_up(heap_context ctx, int i, void *elt) {
109 for ( p = heap_parent(i);
110 i > 1 && ctx->higher_priority(elt, ctx->heap[p]);
111 i = p, p = heap_parent(i) ) {
112 ctx->heap[i] = ctx->heap[p];
114 (ctx->index)(ctx->heap[i], i);
116 ctx->heap[i] = elt;
118 (ctx->index)(ctx->heap[i], i);
122 sink_down(heap_context ctx, int i, void *elt) {
127 while (i <= half_size) {
129 j = heap_left(i);
135 ctx->heap[i] = ctx->heap[j];
137 (ctx->index)(ctx->heap[i], i);
138 i = j;
140 ctx->heap[i] = elt;
142 (ctx->index)(ctx->heap[i], i);
147 int i;
154 i = ++ctx->heap_size;
158 float_up(ctx, i, elt);
164 heap_delete(heap_context ctx, int i) {
168 if (ctx == NULL || i < 1 || i > ctx->heap_size) {
173 if (i == ctx->heap_size) {
177 less = ctx->higher_priority(elt, ctx->heap[i]);
178 ctx->heap[i] = elt;
180 float_up(ctx, i, ctx->heap[i]);
182 sink_down(ctx, i, ctx->heap[i]);
189 heap_increased(heap_context ctx, int i) {
190 if (ctx == NULL || i < 1 || i > ctx->heap_size) {
195 float_up(ctx, i, ctx->heap[i]);
201 heap_decreased(heap_context ctx, int i) {
202 if (ctx == NULL || i < 1 || i > ctx->heap_size) {
207 sink_down(ctx, i, ctx->heap[i]);
213 heap_element(heap_context ctx, int i) {
214 if (ctx == NULL || i < 1 || i > ctx->heap_size) {
219 return (ctx->heap[i]);
224 int i;
231 for (i = 1; i <= ctx->heap_size; i++)
232 (action)(ctx->heap[i], uap);