
(/VERSIONCHECK 2) 

(DEFUN |HEAP;empty;$;1| ($) (SPADCALL (QREFELT $ 8))) 

(DEFUN |HEAP;heap;L$;2| (|l| $)
  (PROG (#1=#:G671 |x| |h| |n|)
    (RETURN
     (SEQ (LETT |n| (LENGTH |l|) . #2=(|HEAP;heap;L$;2|))
          (LETT |h| (SPADCALL (QREFELT $ 9)) . #2#)
          (EXIT
           (COND ((EQL |n| 0) |h|)
                 ('T
                  (SEQ
                   (SEQ (LETT |x| NIL . #2#) (LETT #1# |l| . #2#) G190
                        (COND
                         ((OR (ATOM #1#)
                              (PROGN (LETT |x| (CAR #1#) . #2#) NIL))
                          (GO G191)))
                        (SEQ (EXIT (SPADCALL |x| |h| (QREFELT $ 10))))
                        (LETT #1# (CDR #1#) . #2#) (GO G190) G191 (EXIT NIL))
                   (EXIT |h|))))))))) 

(DEFUN |HEAP;siftUp| (|r| |i| |n| $)
  (PROG (#1=#:G676 |j| |k| |t|)
    (RETURN
     (SEQ (LETT |t| (SPADCALL |r| |i| (QREFELT $ 14)) . #2=(|HEAP;siftUp|))
          (EXIT
           (SEQ
            (EXIT
             (SEQ G190
                  (COND
                   ((NULL
                     (< (LETT |j| (+ (SPADCALL 2 |i| (QREFELT $ 16)) 1) . #2#)
                        |n|))
                    (GO G191)))
                  (SEQ
                   (SEQ (LETT |k| (+ |j| 1) . #2#)
                        (EXIT
                         (COND
                          ((< |k| |n|)
                           (COND
                            ((SPADCALL (SPADCALL |r| |j| (QREFELT $ 14))
                                       (SPADCALL |r| |k| (QREFELT $ 14))
                                       (QREFELT $ 18))
                             (LETT |j| |k| . #2#)))))))
                   (EXIT
                    (COND
                     ((SPADCALL |t| (SPADCALL |r| |j| (QREFELT $ 14))
                                (QREFELT $ 18))
                      (SEQ
                       (SPADCALL |r| |i| (SPADCALL |r| |j| (QREFELT $ 14))
                                 (QREFELT $ 19))
                       (SPADCALL |r| |j| |t| (QREFELT $ 19))
                       (EXIT (LETT |i| |j| . #2#))))
                     ('T (PROGN (LETT #1# |$NoValue| . #2#) (GO #1#))))))
                  NIL (GO G190) G191 (EXIT NIL)))
            #1# (EXIT #1#))))))) 

(DEFUN |HEAP;extract!;$S;4| (|r| $)
  (PROG (|t| |n|)
    (RETURN
     (SEQ (LETT |n| (SPADCALL |r| (QREFELT $ 21)) . #1=(|HEAP;extract!;$S;4|))
          (EXIT
           (COND ((EQL |n| 0) (|error| "empty heap"))
                 (#2='T
                  (SEQ (LETT |t| (SPADCALL |r| 0 (QREFELT $ 14)) . #1#)
                       (SPADCALL |r| 0 (SPADCALL |r| (- |n| 1) (QREFELT $ 14))
                                 (QREFELT $ 19))
                       (SPADCALL |r| (- |n| 1) (QREFELT $ 22))
                       (EXIT
                        (COND ((EQL |n| 1) |t|)
                              (#2#
                               (SEQ (|HEAP;siftUp| |r| 0 (- |n| 1) $)
                                    (EXIT |t|))))))))))))) 

(DEFUN |HEAP;insert!;S2$;5| (|x| |r| $)
  (PROG (|j| #1=#:G685 |i|)
    (RETURN
     (SEQ (LETT |j| (SPADCALL |r| (QREFELT $ 21)) . #2=(|HEAP;insert!;S2$;5|))
          (LETT |r|
                (SPADCALL |r|
                          (SPADCALL |x| (SPADCALL (QREFELT $ 8))
                                    (QREFELT $ 24))
                          (QREFELT $ 25))
                . #2#)
          (SEQ
           (EXIT
            (SEQ G190 (COND ((NULL (< 0 |j|)) (GO G191)))
                 (SEQ (LETT |i| (QUOTIENT2 (- |j| 1) 2) . #2#)
                      (COND
                       ((NULL
                         (SPADCALL (SPADCALL |r| |i| (QREFELT $ 14)) |x|
                                   (QREFELT $ 18)))
                        (PROGN (LETT #1# |$NoValue| . #2#) (GO #1#))))
                      (SPADCALL |r| |j| (SPADCALL |r| |i| (QREFELT $ 14))
                                (QREFELT $ 19))
                      (EXIT (LETT |j| |i| . #2#)))
                 NIL (GO G190) G191 (EXIT NIL)))
           #1# (EXIT #1#))
          (SPADCALL |r| |j| |x| (QREFELT $ 19)) (EXIT |r|))))) 

(DEFUN |HEAP;max;$S;6| (|r| $)
  (COND ((EQL (SPADCALL |r| (QREFELT $ 21)) 0) (|error| "empty heap"))
        ('T (SPADCALL |r| 0 (QREFELT $ 14))))) 

(DEFUN |HEAP;inspect;$S;7| (|r| $) (SPADCALL |r| (QREFELT $ 26))) 

(DEFUN |HEAP;makeHeap| (|r| $)
  (PROG (|k| |n|)
    (RETURN
     (SEQ (LETT |n| (SPADCALL |r| (QREFELT $ 21)) . #1=(|HEAP;makeHeap|))
          (SEQ (LETT |k| (- (QUOTIENT2 |n| 2) 1) . #1#) G190
               (COND ((< |k| 0) (GO G191)))
               (SEQ (EXIT (|HEAP;siftUp| |r| |k| |n| $)))
               (LETT |k| (+ |k| -1) . #1#) (GO G190) G191 (EXIT NIL))
          (EXIT |r|))))) 

(DEFUN |HEAP;bag;L$;9| (|l| $)
  (|HEAP;makeHeap| (SPADCALL |l| (QREFELT $ 28)) $)) 

(DEFUN |HEAP;merge;3$;10| (|a| |b| $)
  (|HEAP;makeHeap| (SPADCALL |a| |b| (QREFELT $ 30)) $)) 

(DEFUN |HEAP;merge!;3$;11| (|a| |b| $)
  (|HEAP;makeHeap| (SPADCALL |a| |b| (QREFELT $ 25)) $)) 

(DEFUN |Heap| (#1=#:G700)
  (PROG ()
    (RETURN
     (PROG (#2=#:G701)
       (RETURN
        (COND
         ((LETT #2#
                (|lassocShiftWithFunction| (LIST (|devaluate| #1#))
                                           (HGET |$ConstructorCache| '|Heap|)
                                           '|domainEqualList|)
                . #3=(|Heap|))
          (|CDRwithIncrement| #2#))
         ('T
          (UNWIND-PROTECT (PROG1 (|Heap;| #1#) (LETT #2# T . #3#))
            (COND ((NOT #2#) (HREM |$ConstructorCache| '|Heap|))))))))))) 

(DEFUN |Heap;| (|#1|)
  (PROG (|pv$| #1=#:G699 $ |dv$| DV$1)
    (RETURN
     (PROGN
      (LETT DV$1 (|devaluate| |#1|) . #2=(|Heap|))
      (LETT |dv$| (LIST '|Heap| DV$1) . #2#)
      (LETT $ (GETREFV 40) . #2#)
      (QSETREFV $ 0 |dv$|)
      (QSETREFV $ 3
                (LETT |pv$|
                      (|buildPredVector| 0 0
                                         (LIST
                                          (LETT #1#
                                                (|HasCategory| |#1|
                                                               '(|SetCategory|))
                                                . #2#)
                                          (AND #1#
                                               (|HasCategory| |#1|
                                                              (LIST '|Evalable|
                                                                    (|devaluate|
                                                                     |#1|))))))
                      . #2#))
      (|haddProp| |$ConstructorCache| '|Heap| (LIST DV$1) (CONS 1 $))
      (|stuffDomainSlots| $)
      (QSETREFV $ 6 |#1|)
      (AND (|HasCategory| $ '(|shallowlyMutable|)) (|augmentPredVector| $ 4))
      (AND (|HasCategory| $ '(|finiteAggregate|)) (|augmentPredVector| $ 8))
      (AND (|HasCategory| $ '(|finiteAggregate|)) #1#
           (|augmentPredVector| $ 16))
      (QSETREFV $ 7 (|IndexedFlexibleArray| |#1| 0))
      $)))) 

(MAKEPROP '|Heap| '|infovec|
          (LIST
           '#(NIL NIL NIL NIL NIL (|IndexedFlexibleArray| 6 (NRTEVAL 0))
              (|local| |#1|) '|Rep| (0 . |empty|) |HEAP;empty;$;1|
              |HEAP;insert!;S2$;5| (|List| 6) |HEAP;heap;L$;2| (|Integer|)
              (4 . |elt|) (|PositiveInteger|) (10 . *) (|Boolean|) (16 . <)
              (22 . |setelt|) (|NonNegativeInteger|) (29 . |#|)
              (34 . |delete!|) |HEAP;extract!;$S;4| (40 . |concat|)
              (46 . |concat!|) |HEAP;max;$S;6| |HEAP;inspect;$S;7|
              (52 . |construct|) |HEAP;bag;L$;9| (57 . |concat|)
              |HEAP;merge;3$;10| |HEAP;merge!;3$;11| (|List| 34) (|Equation| 6)
              (|Mapping| 17 6) (|Mapping| 6 6) (|SingleInteger|) (|OutputForm|)
              (|String|))
           '#(~= 63 |size?| 69 |sample| 75 |parts| 79 |more?| 84 |merge!| 90
              |merge| 96 |members| 102 |member?| 107 |max| 113 |map!| 118 |map|
              124 |less?| 130 |latex| 136 |inspect| 141 |insert!| 146 |heap|
              152 |hash| 157 |extract!| 162 |every?| 167 |eval| 173 |eq?| 199
              |empty?| 205 |empty| 210 |count| 214 |copy| 226 |coerce| 231
              |bag| 236 |any?| 241 = 247 |#| 253)
           'NIL
           (CONS (|makeByteWordVec2| 2 '(0 0 0 0 2 1 0 0 0 2 1 1))
                 (CONS
                  '#(NIL |BagAggregate&| |HomogeneousAggregate&| |Aggregate&|
                     |Evalable&| |SetCategory&| NIL NIL NIL |InnerEvalable&|
                     |BasicType&| NIL)
                  (CONS
                   '#((|PriorityQueueAggregate| 6) (|BagAggregate| 6)
                      (|HomogeneousAggregate| 6) (|Aggregate|) (|Evalable| 6)
                      (|SetCategory|) (|Type|) (|finiteAggregate|)
                      (|shallowlyMutable|) (|InnerEvalable| 6 6) (|BasicType|)
                      (|CoercibleTo| 38))
                   (|makeByteWordVec2| 39
                                       '(0 7 0 8 2 7 6 0 13 14 2 13 0 15 0 16 2
                                         6 17 0 0 18 3 7 6 0 13 6 19 1 0 20 0
                                         21 2 7 0 0 13 22 2 7 0 6 0 24 2 7 0 0
                                         0 25 1 7 0 11 28 2 7 0 0 0 30 2 1 17 0
                                         0 1 2 0 17 0 20 1 0 0 0 1 1 4 11 0 1 2
                                         0 17 0 20 1 2 0 0 0 0 32 2 0 0 0 0 31
                                         1 4 11 0 1 2 5 17 6 0 1 1 0 6 0 26 2 3
                                         0 36 0 1 2 0 0 36 0 1 2 0 17 0 20 1 1
                                         1 39 0 1 1 0 6 0 27 2 0 0 6 0 10 1 0 0
                                         11 12 1 1 37 0 1 1 0 6 0 23 2 4 17 35
                                         0 1 3 2 0 0 11 11 1 3 2 0 0 6 6 1 2 2
                                         0 0 33 1 2 2 0 0 34 1 2 0 17 0 0 1 1 0
                                         17 0 1 0 0 0 9 2 5 20 6 0 1 2 4 20 35
                                         0 1 1 0 0 0 1 1 1 38 0 1 1 0 0 11 29 2
                                         4 17 35 0 1 2 1 17 0 0 1 1 4 20 0
                                         21)))))
           '|lookupComplete|)) 
