From 2a8643e936ca163c702c4acd3bcb84da42aa6d86 Mon Sep 17 00:00:00 2001 From: Jon Harper Date: Wed, 9 Jan 2019 20:18:30 +0100 Subject: [PATCH] heaps: bring back data-compare as heapdata-compare 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/basis/heaps/heaps.factor b/basis/heaps/heaps.factor index ab8dc1d68f..d758f18c77 100644 --- a/basis/heaps/heaps.factor +++ b/basis/heaps/heaps.factor @@ -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 ]