[Turn off line numbering]1: arg heap, element, priority_ind; 2: var i, j; 3: 4: i = listlen(heap) + 1; 5: if (i == 1) 6: return [element]; 7: anticipate_assignment(); 8: heap += [0]; 9: while (i > 1 && element[priority_ind] < heap[(j = i / 2)][priority_ind]) 10: heap = replace(heap, i, heap[(i = j)]); 11: heap = heap.replace(i, element); 12: return heap;
// Miroslav Silovic
// Created 24-Nov-1996 as a part of ColdCore, see: @help Credit