Skip to content
This repository has been archived by the owner on May 16, 2021. It is now read-only.

Latest commit

 

History

History
29 lines (22 loc) · 718 Bytes

README.md

File metadata and controls

29 lines (22 loc) · 718 Bytes

heap

Thread-safe heap (priority queue) implementations for Common Lisp. Initial implementation includes splay heaps.

Usage:

(let ((heap (heap:make-heap))
      (items (loop for i from 0 below 1024
                   for x = (random 1024)
                   collect x
                   when (zerop (mod i 2)) collect x)))

  (dolist (x items)
    (heap:heap-push heap x x))

  (assert (= (length items) (heap::heap-count heap)))

  (loop for x in (sort items #'<)
        do (multiple-value-bind (next pri empty-p)
               (heap:heap-pop heap)
             (assert (not empty-p))
             (assert (= next pri))
             (assert (= next x))))

  (assert (zerop (heap::heap-count heap))))