JuliaCollections / JuliaCollections/DataStructures.jl
Shouldn't iterate(::MultiDict) return each pair, like it was inserted?
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 745
- Forks
- 261
- PR merge metrics
- No merged PRs in 30d
Description
This feels wrong and surprising to me:
julia> d = DataStructures.MultiDict{Int,Int}()
MultiDict{Int64,Int64}(Dict{Int64,Array{Int64,1}}())
julia> insert!(d, 1,1)
MultiDict{Int64,Int64}(Dict(1 => [1]))
julia> insert!(d, 1,2)
MultiDict{Int64,Int64}(Dict(1 => [1, 2]))
julia> collect(d)
1-element Array{Pair{Int64,Array{Int64,1}},1}:
1 => [1, 2]
I would've expected iterating d to return the two pairs that I inserted! That is, I expected [1=>1, 1=>2].
Can we change it to this? Does this match others' expectations?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the iterate(::MultiDict) entry point and checking how insert! and collect(d) currently interact. Review the existing MultiDict tests, if present, and establish whether iteration should preserve duplicate pairs and insertion order. Done means the intended behavior is agreed and covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 22/100