]> gitweb.factorcode.org Git - factor.git/commitdiff
heaps: use before? and after?.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 10 Jul 2014 01:12:10 +0000 (18:12 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 10 Jul 2014 14:53:13 +0000 (07:53 -0700)
basis/heaps/heaps.factor

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