 
 M: bad-heap-delete summary 
     drop "Invalid entry passed to heap-delete" ;
-    
+
 : entry>index ( entry heap -- n )
     over heap>> eq? [ bad-heap-delete ] unless
     index>> ;


: (child) ( m heap -- n )
    { [ drop ] [ left-value ] [ right-value ] [ nip ] } 2cleave
    heap-compare [ right ] [ left ] if ;

: child ( m heap -- n )
    2dup right-bounds-check?
    [ drop left ] [ (child) ] if ;

DEFER: down-heap


: continue? ( m n heap -- ? )
    [ data-nth nip ]
    [ nip data-nth ]
    [ 2nip ] 3tri heap-compare ; inline

DEFER: up-heap

