Vocabulary
heaps

Inputs
entryan entry
heapa heap


Outputs
None

Word description
Remove the specified entry from the heap.

Errors
Throws an error if the entry is from another heap or if it has already been deleted.

Side effects
Modifies heap

Definition

GENERIC: heap-delete ( entry heap -- )


Methods

M:: heap heap-delete ( entry heap -- )
entry heap entry>index
:> n heap data>> :> data data pop :> nth-entry f entry
index<< n data length = [
nth-entry n data data-set-nth n 0 =
[ t ] [ nth-entry n up data data-nth heap heap-compare ]
if [ heap n sift-up ] [ heap 0 n sift-down ] if
] unless ;