-
Notifications
You must be signed in to change notification settings - Fork 6
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
base: main
Are you sure you want to change the base?
Changes from all commits
e423454
e821100
b00bb23
6ab6d21
008566f
94c93eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)) () | ||
"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)) () | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)))) | ||
|
||
|
@@ -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)) | ||
|
||
|
@@ -122,7 +127,7 @@ | |
|
||
(defun test-dequeue-and-peek (queue list) | ||
(let ((counter (q:size queue))) | ||
(dotimes (i (length list)) | ||
(dolist (i (sort list '<)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This mutates the input list which might cause confusion. Change |
||
(test-peek queue (stringify i) t) | ||
(assert (= counter (q:size queue))) | ||
(test-dequeue queue (stringify i) t) | ||
|
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.