heaps: use before? and after?.

db4
John Benediktsson 2014-07-09 18:12:10 -07:00
parent 6731b0fed4
commit 6ab848775e
1 changed files with 4 additions and 5 deletions

View File

@ -83,12 +83,11 @@ M: heap heap-size ( heap -- n )
GENERIC: heap-compare ( entry1 entry2 heap -- ? ) GENERIC: heap-compare ( entry1 entry2 heap -- ? )
: entry<=> ( entry1 entry2 -- <=> ) M: min-heap heap-compare
{ entry entry } declare [ key>> ] compare ; inline drop { entry entry } declare [ key>> ] bi@ after? ; inline
M: min-heap heap-compare drop entry<=> +gt+ eq? ; M: max-heap heap-compare
drop { entry entry } declare [ key>> ] bi@ before? ; inline
M: max-heap heap-compare drop entry<=> +lt+ eq? ;
: heap-bounds-check? ( m heap -- ? ) : heap-bounds-check? ( m heap -- ? )
heap-size >= ; inline heap-size >= ; inline