Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge changes from 3b #13

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions damn-fast-priority-queue/test.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@
;;;; Utilities

(defun verify-heap-property (vector)
(declare (type q::prio-vector-type vector))
(loop with length = (length vector)
for parent from 0 below (truncate length 2)
for left = (+ (* parent 2) 1)
for right = (+ (* parent 2) 2)
do (assert (< (aref vector parent) (aref vector left)) ()
do (assert (<= (aref vector parent) (aref vector left)) ()
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In which case can these two be equal? Objects with equal priorities, or something?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, judging by the commit comment and the added test, that seems to be the intent.

"VERIFY-HEAP-PROPERTY: Invalid left child: ~D -> ~D"
(aref vector parent) (aref vector left))
when (oddp length)
do (assert (< (aref vector parent) (aref vector right)) ()
do (assert (<= (aref vector parent) (aref vector right)) ()
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

"VERIFY-HEAP-PROPERTY: Invalid right child: ~D -> ~D"
(aref vector parent) (aref vector right))))

Expand All @@ -39,6 +40,10 @@
(perform-test queue (nreverse (a:iota length)))
(dotimes (i 100)
(perform-test queue (a:shuffle (a:iota length))))))
(let ((queue (q:make-queue 64)))
(perform-test queue (alexandria:shuffle (append (a:iota 64)
(a:iota 32)
(a:iota 16)))))
(perform-error-test)
(perform-copy-test))

Expand Down Expand Up @@ -122,7 +127,7 @@

(defun test-dequeue-and-peek (queue list)
(let ((counter (q:size queue)))
(dotimes (i (length list))
(dolist (i (sort list '<))
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mutates the input list which might cause confusion. Change list to (copy-list list).

(test-peek queue (stringify i) t)
(assert (= counter (q:size queue)))
(test-dequeue queue (stringify i) t)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
;;;; damn-fast-updatable-priority-queue.asd

(asdf:defsystem #:damn-fast-updatable-priority-queue
:description "A heap-based priority queue with delete and adjust-priority whose first and foremost priority is speed."
:author "Michał \"phoe\" Herda <[email protected]>"
:license "MIT"
:version "0.0.2"
:serial t
:depends-on (#:alexandria)
:components ((:file "src"))
:in-order-to ((test-op (load-op #:damn-fast-updatable-priority-queue/test)))
:perform (test-op (o c) (symbol-call "DAMN-FAST-UPDATABLE-PRIORITY-QUEUE/TEST" "RUN")))

(asdf:defsystem #:damn-fast-updatable-priority-queue/test
:description "Tests for Damn Fast Priority Queue"
:author "Michał \"phoe\" Herda <[email protected]>"
:license "MIT"
:version "0.0.2"
:serial t
:depends-on (#:alexandria #:damn-fast-updatable-priority-queue)
:components ((:file "test")))
Comment on lines +3 to +21
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modify to take "updatable" into account, also add @3b as a co-author.

Loading