]> gitweb.factorcode.org Git - factor.git/commitdiff
heaps: bring back data-compare as heapdata-compare
authorJon Harper <jon.harper87@gmail.com>
Wed, 9 Jan 2019 19:18:30 +0000 (20:18 +0100)
committerJon Harper <jon.harper87@gmail.com>
Thu, 10 Jan 2019 17:21:02 +0000 (18:21 +0100)
It is useful in several places. Change the name because
0d7233f2daa9c changed the convention and data-* words now
operate on the data directly

basis/heaps/heaps.factor

index ab8dc1d68f8b5db77b7e9e856d3d70fb0cd2d5d6..d758f18c778aa23f632ea62e0e9460b6d6fdd71b 100644 (file)
@@ -70,6 +70,12 @@ M: min-heap heap-compare
 M: max-heap heap-compare
     drop { entry entry } declare [ key>> ] bi@ before? ; inline
 
+: (heapdata-compare) ( m n data heap -- ? )
+    [ '[ _ data-nth ] bi@ ] [ heap-compare ] bi* ; inline
+
+: heapdata-compare ( m n heap -- ? )
+    [ data>> ] keep (heapdata-compare) ; inline
+
 PRIVATE>
 
 : >entry< ( entry -- value key )
@@ -117,7 +123,7 @@ M: heap heap-push*
     n dup left [ dup end < ] [
         dup 1 fixnum+fast
         dup end < [
-            2dup [ data data-nth ] bi@ heap heap-compare
+            2dup data heap (heapdata-compare)
         ] [ f ] if
         [ nip ] [ drop ] if
         [ data data-nth swap data data-set-nth ]