[Turn off line numbering]1: arg heap, i, priority_ind; 2: var j, len, min; 3: 4: len = listlen(heap); 5: if (i > len) 6: throw(~invarg, "Index %d out of bounds - can't delete".format(i)); 7: anticipate_assignment(); 8: while (i != len) { 9: min = len; 10: j = i * 2; 11: if (j < len && heap[j][priority_ind] < heap[min][priority_ind]) 12: min = j; 13: j++; 14: if (j < len && heap[j][priority_ind] < heap[min][priority_ind]) 15: min = j; 16: heap = replace(heap, i, heap[min]); 17: i = min; 18: } 19: heap = heap.subrange(1, len - 1); 20: return heap;
// Miroslav Silovic
// Created 24-Nov-1996 as a part of ColdCore, see: @help Credit