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

Merge changes from 3b #13

wants to merge 6 commits into from

Conversation

phoe
Copy link
Owner

@phoe phoe commented Dec 10, 2021

@3b Will you mind if I review and merge your changes back into my branch? They seem backwards-compatible and should need just a bit of documentation.

Copy link
Owner Author

@phoe phoe left a comment

Choose a reason for hiding this comment

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

TODO: documentation.

@@ -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).

(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.

Comment on lines +3 to +21
(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")))
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.

Comment on lines +21 to +25
#+real-damn-fast-priority-queue
;; Good luck.
`(optimize (speed 3) (debug 0) (safety 0) (space 0) (compilation-speed 0))
#-real-damn-fast-priority-queue
`(optimize (speed 3))))
Copy link
Owner Author

Choose a reason for hiding this comment

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

Use a separate conditional, real-damn-fast-updatable-priority-queue.

(perform-test queue (nreverse (a:iota length)))
(dotimes (i 100)
(perform-test queue (a:shuffle (a:iota length))))))
(perform-error-test)
Copy link
Owner Author

Choose a reason for hiding this comment

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

We seem to be missing the shuffle test here, the one that was added in standard DFPQ tests.

@@ -193,6 +194,18 @@
:peek-fn (lambda (q) (damn-fast-priority-queue:peek q))
:pop-fn (lambda (q) (damn-fast-priority-queue:dequeue q))))

(defun test-damn-fast-updatable-priority-queue (vector-name vector)
Copy link
Owner Author

Choose a reason for hiding this comment

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

Update the docs with the new benchmark results.

@3b
Copy link

3b commented Dec 13, 2021

Been a while since i looked at this stuff, but i think merging it should be OK. I don't see any important looking changes in my local copy, just debugging noise. will try to take a closer look at it at some point though.

@azimut
Copy link

azimut commented Dec 17, 2021

is possible with this or with any damn-fast-*-priority-queue to dequeue and also get the priority number?

@3b
Copy link

3b commented Dec 18, 2021

It doesn't look like it, though that does sound like something that could be useful to have.
Maybe the "found" value of dequeue and peek could be changed to return priority in place of T? (at least for the updatable variant, since it hadn't been merged yet. not sure if that would be too big a change for the existing ones or not.)

@phoe
Copy link
Owner Author

phoe commented Dec 18, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants