Heap extraction and reorganization


function extract( var r : RecordArray ) : typekey; begin if n<1 then Error {*** extracting from an empty Heap ***} else begin extract := r[1].k; r[1] := r[n]; n := n-1; siftup( r, 1, n ) end end;

Pascal source (513.extr.p)



© Addison-Wesley Publishing Co. Inc.