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

Add support for strings as key #42

Open
nermin99 opened this issue Dec 22, 2021 · 1 comment
Open

Add support for strings as key #42

nermin99 opened this issue Dec 22, 2021 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@nermin99
Copy link

priorityQueue.push("x,y", 10)
priorityQueue.push("a", 20)
console.log(priorityQueue.pop())    // 0
console.log(priorityQueue.peek())   // 0

The output should be

"x,y"
"a"

I want to use Dijkstra's algorithm on a 2D-array grid. Using indexes as keys and the number value at that position as weight.

@luciopaiva
Copy link
Owner

I'm pretty sure you were doing AoC21 day 15 when you requested this, am I right? 😂

Your request makes total sense. I do want to introduce support for keys of types other than numbers, but that will impose a speed penalty since I won't be able to use typed arrays anymore, which is what makes Heapify so fast. Anyway, I do think that Heapify should evolve towards better usability, even if it means sacrificing eficiency, so I think this is worth doing. We should see this change by the time v1.0 is released.

Thanks for your sugestion.

@luciopaiva luciopaiva added the enhancement New feature or request label Dec 28, 2021
@luciopaiva luciopaiva added this to the v1.0 milestone Dec 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
2 participants