;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. #@63 Evaluate THEN if `generator' library is available. (fn THEN) (defalias 'heap--when-generators '(macro . #[257 "\300\301\302\303#\205 \211\207" [require generator nil noerror] 5 (#$ . 87)])) (put 'heap--when-generators 'edebug-form-spec t) #@64 compiler-macro for inlining `heap--p'. (fn CL-WHOLE-ARG CL-X) (defalias 'heap--p--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block heap--p (and (memq (type-of cl-x) cl-struct-heap--tags) t)) nil] 9 (#$ . 334)]) (put 'heap--p 'compiler-macro 'heap--p--cmacro) #@13 (fn CL-X) (defalias 'heap--p #[257 "\301!>\205 \302\207" [cl-struct-heap--tags type-of t] 3 (#$ . 637)]) (byte-code "\300\301\302\303#\304\305\306\301#\207" [function-put heap--p side-effect-free error-free put heap- cl-deftype-satisfies] 5) #@67 compiler-macro for inlining `heap--vect'. (fn CL-WHOLE-ARG CL-X) (defalias 'heap--vect--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block heap--vect (progn (or (heap--p cl-x) (signal 'wrong-type-argument (list 'heap- cl-x))) (aref cl-x 1))) nil] 9 (#$ . 890)]) (put 'heap--vect 'compiler-macro 'heap--vect--cmacro) #@55 Access slot "vect" of `heap-' struct CL-X. (fn CL-X) (defalias 'heap--vect #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-heap--tags type-of signal wrong-type-argument heap- 1] 5 (#$ . 1248)]) (byte-code "\300\301\302\303#\300\207" [function-put heap--vect side-effect-free t] 4) #@69 compiler-macro for inlining `heap--cmpfun'. (fn CL-WHOLE-ARG CL-X) (defalias 'heap--cmpfun--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block heap--cmpfun (progn (or (heap--p cl-x) (signal 'wrong-type-argument (list 'heap- cl-x))) (aref cl-x 2))) nil] 9 (#$ . 1555)]) (put 'heap--cmpfun 'compiler-macro 'heap--cmpfun--cmacro) #@57 Access slot "cmpfun" of `heap-' struct CL-X. (fn CL-X) (defalias 'heap--cmpfun #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-heap--tags type-of signal wrong-type-argument heap- 2] 5 (#$ . 1924)]) (byte-code "\300\301\302\303#\300\207" [function-put heap--cmpfun side-effect-free t] 4) #@68 compiler-macro for inlining `heap--count'. (fn CL-WHOLE-ARG CL-X) (defalias 'heap--count--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block heap--count (progn (or (heap--p cl-x) (signal 'wrong-type-argument (list 'heap- cl-x))) (aref cl-x 3))) nil] 9 (#$ . 2237)]) (put 'heap--count 'compiler-macro 'heap--count--cmacro) #@56 Access slot "count" of `heap-' struct CL-X. (fn CL-X) (defalias 'heap--count #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-heap--tags type-of signal wrong-type-argument heap- 3] 5 (#$ . 2601)]) (byte-code "\300\301\302\303#\300\207" [function-put heap--count side-effect-free t] 4) #@67 compiler-macro for inlining `heap--size'. (fn CL-WHOLE-ARG CL-X) (defalias 'heap--size--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block heap--size (progn (or (heap--p cl-x) (signal 'wrong-type-argument (list 'heap- cl-x))) (aref cl-x 4))) nil] 9 (#$ . 2911)]) (put 'heap--size 'compiler-macro 'heap--size--cmacro) #@55 Access slot "size" of `heap-' struct CL-X. (fn CL-X) (defalias 'heap--size #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-heap--tags type-of signal wrong-type-argument heap- 4] 5 (#$ . 3270)]) (byte-code "\300\301\302\303#\300\207" [function-put heap--size side-effect-free t] 4) #@69 compiler-macro for inlining `heap--resize'. (fn CL-WHOLE-ARG CL-X) (defalias 'heap--resize--cmacro #[514 "\300\301\302\303\211\211&\207" [cl--defsubst-expand (cl-x) (cl-block heap--resize (progn (or (heap--p cl-x) (signal 'wrong-type-argument (list 'heap- cl-x))) (aref cl-x 5))) nil] 9 (#$ . 3577)]) (put 'heap--resize 'compiler-macro 'heap--resize--cmacro) #@57 Access slot "resize" of `heap-' struct CL-X. (fn CL-X) (defalias 'heap--resize #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-heap--tags type-of signal wrong-type-argument heap- 5] 5 (#$ . 3946)]) (byte-code "\300\301\302\303#\300\207" [function-put heap--resize side-effect-free t] 4) #@86 Constructor for objects of type `heap-'. (fn CMPFUN &optional (SIZE 10) (RESIZE 2)) (defalias 'heap--create #[385 "\211\203 \211A\262\242\202\300\203\211A\262\242\202\301\302\303\"\203/\304\305\306\307G\\D\"\210\310\311\312&\207" [10 2 make-vector nil signal wrong-number-of-arguments heap--create 3 record heap- 0] 12 (#$ . 4259)]) (byte-code "\300\301\302\303#\304\305\306\307\310\306\311\312\305\303& \207" [function-put heap--create side-effect-free t cl-struct-define heap- nil cl-structure-object record ((cl-tag-slot) (vect) (cmpfun) (count) (size) (resize)) cl-struct-heap--tags] 11) #@15 (fn HEAP I) (defalias 'heap--child #[514 "\301!>\204\302\303\304D\"\210\305H\301!>\204!\302\303\304D\"\210\306H\301!>\2044\302\303\304D\"\210\307H\310\307_\211TY?\205\204\306\\Y\203N\211T\207TH\306\\H\"\203b\211T\202e\306\\\262\307\\Y\203q\207H\307\\H\"\203\201\207\307\\\207" [cl-struct-heap--tags type-of signal wrong-type-argument heap- 1 2 3 nil] 12 (#$ . 4883)]) #@17 (fn VECT I J) (defalias 'heap--vswap #[771 "HHI\210I\210\207" [] 8 (#$ . 5305)]) (byte-code "\300\301\302\303#\304\301\305\306#\207" [function-put heap--vswap speed -1 put byte-optimizer byte-compile-inline-expand] 5) #@15 (fn HEAP N) (defalias 'heap--sift-up #[514 "\211\301\302!>\204\303\304\305D\"\210\306H\211H\307V\205\\\302!>\204/\303\304\305D\"\210\310HS\311\245\211\262H\"\205\\HHI\210I\210\266\262\202\207" [cl-struct-heap--tags nil type-of signal wrong-type-argument heap- 1 0 2 3] 14 (#$ . 5541)]) #@15 (fn HEAP N) (defalias 'heap--sift-down #[514 "\301!>\204\302\303\304D\"\210\305H\301!>\204!\302\303\304D\"\210\306H\307\"H\205[H\"\205[HHI\210I\210\266\262\307\"\262\202,\207" [cl-struct-heap--tags type-of signal wrong-type-argument heap- 1 2 heap--child] 15 (#$ . 5876)]) #@560 Create an empty heap with comparison function COMPARE-FUNCTION. COMPARE-FUNCTION takes two arguments, A and B, and returns non-nil or nil. To implement a max-heap, it should return non-nil if A is greater than B. To implemenet a min-heap, it should return non-nil if A is less than B. Optional argument INITIAL-SIZE sets the initial size of the heap, defaulting to 10. Optional argument RESIZE-FACTOR sets the factor by which the heap's size is increased if it runs out of space, defaulting to 2. (fn COMPARE-FUNCTION &optional INITIAL-SIZE RESIZE-FACTOR) (defalias 'make-heap #[769 "\204\300\262\211\204\301\262\302#\207" [10 2 heap--create] 7 (#$ . 6202)]) (defalias 'heap-create 'make-heap) #@40 Return a copy of heap HEAP. (fn HEAP) (defalias 'heap-copy #[257 "\301\302!>\204\303\304\305D\"\210\306H\302!>\204\"\303\304\305D\"\210\307H\302!>\2045\303\304\305D\"\210\310H#\302!>\204H\303\304\305D\"\210\211\211\311\312\302!>\204]\303\304\305D\"\210\311H!I\266\302!>\204s\303\304\305D\"\210\211\211\313\302!>\204\206\303\304\305D\"\210\313HI\266\207" [cl-struct-heap--tags heap--create type-of signal wrong-type-argument heap- 2 4 5 1 vconcat 3] 10 (#$ . 6915)]) #@58 Return t if the heap is empty, nil otherwise. (fn HEAP) (defalias 'heap-empty #[257 "\301!>\204\302\303\304D\"\210\211\305H\306U\207" [cl-struct-heap--tags type-of signal wrong-type-argument heap- 3 0] 5 (#$ . 7428)]) #@54 Return the number of entries in the heap. (fn HEAP) (defalias 'heap-size #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-heap--tags type-of signal wrong-type-argument heap- 3] 5 (#$ . 7658)]) #@62 Return the comparison function for the heap HEAP. (fn HEAP) (defalias 'heap-compare-function #[257 "\301!>\204\302\303\304D\"\210\211\305H\207" [cl-struct-heap--tags type-of signal wrong-type-argument heap- 2] 5 (#$ . 7876)]) #@56 Add DATA to the heap, and return DATA. (fn HEAP DATA) (defalias 'heap-add #[514 "\301!>\204\302\303\304D\"\210\305H\301!>\204!\302\303\304D\"\210\306H\301!>\2044\302\303\304D\"\210\307HW\203E\211I\210\202\304\301!>\204U\302\303\304D\"\210\211\307\310\301 !>\204j\302\303\304 D\"\210\307H\311 !\312\313 \301!>\204\207\302\303\304D\"\210 \314HS_!S\315\"#I\266\301!>\204\245\302\303\304D\"\210\211\306\313\301\n!>\204\273\302\303\304\fD\"\210 \314H_!I\266\301!>\204\324\302\303\304D\"\210\211\305\301!>\204\350\302\303\304\nD\"\210\305HTI\262\262\316S\"\266\207" [cl-struct-heap--tags type-of signal wrong-type-argument heap- 3 4 1 vconcat vector make-vector ceiling 5 nil heap--sift-up] 18 (#$ . 8114)]) #@61 Return the root of the heap, without removing it (fn HEAP) (defalias 'heap-root #[257 "\301!>\204\302\303\304D\"\210\211\305H\306U?\205,\301!>\204'\302\303\304D\"\210\211\307H\306H\207" [cl-struct-heap--tags type-of signal wrong-type-argument heap- 3 0 1] 5 (#$ . 8899)]) #@69 Return the root of the heap and delete it from the heap. (fn HEAP) (defalias 'heap-delete-root #[257 "\301!>\204\302\303\304D\"\210\211\305H\306\211\301!>\204$\302\303\304D\"\210\307H\310U?\205\203\310H\262\301!>\204B\302\303\304D\"\210\211\307\307HSI\262\262\211\310U\203q\301!>\204d\302\303\304D\"\210\211\305\311\312\306\"I\266\202\202\310HI\210\306I\210\313\310\"\210\207" [cl-struct-heap--tags type-of signal wrong-type-argument heap- 1 nil 3 0 make-vector 10 heap--sift-down] 10 (#$ . 9188)]) #@371 Replace the first heap entry identified by MATCH-FUNCTION with DATA, if a match exists. Return t if there was a match, nil otherwise. The function MATCH-FUNCTION should take one argument of the type stored in the heap, and return non-nil if it should be modified, nil otherwise. Note that only the match highest up the heap is modified. (fn HEAP MATCH-FUNCTION DATA) (defalias 'heap-modify #[771 "\301!>\204\302\303\304D\"\210\305H\301!>\204\"\302\303\304D\"\210\306H\307\211W\203;H!\204;\211T\262\202&\211W\205wHI\210\301!>\204[\302\303\304 D\"\210\310H\"\203n\311\"\210\202t\312\"\210\313\262\207" [cl-struct-heap--tags type-of signal wrong-type-argument heap- 1 3 0 2 heap--sift-up heap--sift-down t] 11 (#$ . 9734)]) #@609 Build a heap from vector VEC with COMPARE-FUNCTION as the comparison function. Note that VEC is modified, and becomes part of the heap data structure. If you don't want this, copy the vector first and pass the copy in VEC. COMPARE-FUNCTION takes two arguments, A and B, and returns non-nil or nil. To implement a max-heap, it should return non-nil if A is greater than B. To implemenet a min-heap, it should return non-nil if A is less than B. RESIZE-FACTOR sets the factor by which the heap's size is increased if it runs out of space, defaulting to 2. (fn COMPARE-FUNCTION VEC &optional RESIZE-FACTOR) (defalias 'heap-build #[770 "\211\204\301\262\302G#\303\304\305\303\306\301G_T\305\"S!\"S\301\"\307!>\204/\310\311\312D\"\210\211\313I\266\307!>\204F\310\311\312D\"\210\211\305GI\266\211S\211\262\314Y\203a\315\"\210\202O\207" [cl-struct-heap--tags 2 heap--create ceiling expt 3 log type-of signal wrong-type-argument heap- 1 0 heap--sift-down] 11 (#$ . 10511)]) #@278 Merge HEAP with remaining HEAPS. The merged heap takes the comparison function and resize-fector of the first HEAP argument. (Note that in this heap implementation, the merge operation is not very efficient, taking O(n) time for combined heap size n). (fn HEAP &rest HEAPS) (defalias 'heap-merge #[385 "\301\302\"\262\303\304!>\204\305\306\307D\"\210\310H\311\312\304!>\204,\305\306\307D\"\210\313H#\304!>\204A\305\306\307D\"\210\314H#\207" [cl-struct-heap--tags mapcar heap--vect heap-build type-of signal wrong-type-argument heap- 2 apply vconcat 1 5] 10 (#$ . 11518)]) #@77 Remove all entries from HEAP. Return number of entries removed. (fn HEAP) (defalias 'heap-clear #[257 "\301!>\204\302\303\304D\"\210\211\305H\301!>\204!\302\303\304D\"\210\211\306\307\301!>\2046\302\303\304D\"\210\306HG\310\"I\266\301!>\204N\302\303\304D\"\210\211\305\311I\266\207" [cl-struct-heap--tags type-of signal wrong-type-argument heap- 3 1 make-vector nil 0] 10 (#$ . 12121)]) #@372 Return a heap iterator object. Calling `iter-next' on this object will retrieve the next element from the heap. The heap itself is not modified. (Note that in this heap implementation, constructing a heap iterator is not very efficient, taking O(n) time for a heap of size n. Each call to `iter-next' on the other hand *is* efficient, taking O(log n) time.) (fn HEAP) (defalias 'heap-iter #[257 "\300C\300C\300C\300\211C\300C\300C\300C\300C\300C\300C\300C\300C\300 \301\302\"\240\210\301\303 \n%\240\210\301\304\f$\240\210\301\305 \f%\240\210\301\306 %\240\210\301\307  %\240\210\301\310 %\240\210\301\311%\240\210\301\312%\262 \240\210\301\313$\207" [nil make-closure #[0 "\301\302\300\242\"\207" [V0 signal iter-end-of-sequence] 3] #[0 "\301\304\302\242!?\300\303\242\240\210\240\207" [V0 V1 V2 V3 heap-empty] 4] #[0 "\300\302\242\240\210\303\304\301\242\"\207" [V0 V1 V2 throw cps--yield] 3] #[0 "\301\304\302\242!\300\303\242\240\210\240\207" [V0 V1 V2 V3 heap-delete-root] 4] #[0 "\300\301\242\203 \303\242\202 \302\242\240\207" [V0 V1 V2 V3] 2] #[0 "\302\301\242\240\210\300\303\242\240\207" [V0 V1 V2 V3] 2] #[0 "\301\302\242\300\303\242\240\210\240\207" [V0 V1 V2 V3] 4] #[0 "\302\301\242\240\210\300\303\242\240\207" [V0 V1 V2 V3] 2] #[0 "\302\304\300!\301\303\242\240\210\240\207" [V0 V1 V2 V3 heap-copy] 4] #[514 "\303\267\202/\300\302\242\240\210\301\304\240\207\301\240\210\304C\305\306\300\301\302%\216\3072)\300\242 \210\202!0\310\240\210)\207\311\312\"\207" [V0 V1 V2 #s(hash-table size 2 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (:close 6 :next 15)) nil make-closure #[0 "\303\242?\205\300\302\242\240\210\301\304\240\207" [V0 V1 V2 V3 nil] 2] cps--yield t error "unknown iterator operation %S"] 9 "\n\n(fn OP VALUE)"]] 22 (#$ . 12541)]) (provide 'heap)