ERROR: instead of throw
parent
a5baa31784
commit
42bd621cce
|
@ -2,7 +2,7 @@
|
||||||
! Slava Pestov.
|
! Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel math sequences arrays assocs sequences.private
|
USING: kernel math sequences arrays assocs sequences.private
|
||||||
growable accessors math.order ;
|
growable accessors math.order summary ;
|
||||||
IN: heaps
|
IN: heaps
|
||||||
|
|
||||||
GENERIC: heap-push* ( value key heap -- entry )
|
GENERIC: heap-push* ( value key heap -- entry )
|
||||||
|
@ -161,10 +161,13 @@ M: heap heap-push* ( value key heap -- entry )
|
||||||
M: heap heap-peek ( heap -- value key )
|
M: heap heap-peek ( heap -- value key )
|
||||||
data-first >entry< ;
|
data-first >entry< ;
|
||||||
|
|
||||||
|
ERROR: bad-heap-delete ;
|
||||||
|
|
||||||
|
M: bad-heap-delete summary
|
||||||
|
drop "Invalid entry passed to heap-delete" ;
|
||||||
|
|
||||||
: entry>index ( entry heap -- n )
|
: entry>index ( entry heap -- n )
|
||||||
over entry-heap eq? [
|
over entry-heap eq? [ bad-heap-delete ] unless
|
||||||
"Invalid entry passed to heap-delete" throw
|
|
||||||
] unless
|
|
||||||
entry-index ;
|
entry-index ;
|
||||||
|
|
||||||
M: heap heap-delete ( entry heap -- )
|
M: heap heap-delete ( entry heap -- )
|
||||||
|
|
Loading…
Reference in New Issue