JuliaCollections / JuliaCollections/DataStructures.jl

define emptymutable for all sets so that map, filter etc return right type

Open
#632 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

We should define Base.emptymutable for all out mutable AbstractSet subtypes.

Consider SortedSet

julia> filter(isodd, SortedSet((1,2,3,4)))
Set{Int64} with 2 elements:
  3
  1

But if we define:

Base.emptymutable(s::SortedSet{T}, ::Type{U}=T) where {T,U} = SortedSet{U}()

then we get

julia> filter(isodd, SortedSet((1,2,3,4)))
SortedSet{Int64,Base.Order.ForwardOrdering} with 2 elements:
  1
  3

see also
https://github.com/JuliaLang/julia/issues/34677#issuecomment-594125450

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 locating the mutable AbstractSet subtypes and their Base.emptymutable entry points, using SortedSet and the filter example in this issue as the initial case. Verify the collection operations shown return the appropriate set type for every applicable subtype and element type.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.