JuliaCollections / JuliaCollections/DataStructures.jl

Should PriorityQueue actually be a dictionary?

Open
#690 2 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
745
Forks
261
PR merge metrics
No merged PRs in 30d

Description

Currently, PriorityQueue is implemented as an AbstractDict by wrapping a Dict instance. Apparently, this design mixes two different data structures, and since this leads to performance issues (e.g., https://github.com/JuliaCollections/DataStructures.jl/issues/596) I'm wondering if this should be changed.

Instead, alternatively PriorityQueue could be implemented as a wrapper of a heap structure for pairs (by default a BinaryHeap but adjustable by the user) that provides a consistent interface for accessing the top element, its key and its value, removing the top element, and inserting elements, without additionally serving as a dictionary (similar to, e.g., the std::priority_queue in C++). If users need a dictionary structure as well, they can create one independently of the PriorityQueue. This separation would also make it easier to use alternative dictionary types such as SwissDict or RobinDict.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the current PriorityQueue implementation and the linked performance discussion. Compare the AbstractDict/Dict design with the proposed BinaryHeap-backed interface, then establish the intended API and compatibility expectations before implementation; done requires an agreed design and corresponding behavior and performance validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.