andyferris / Dictionaries.jl

An alternative interface for dictionaries in Julia, for improved productivity and performance
Other
282 stars 28 forks source link

Missing methods for some set operations between `AbstractIndices` and `itr` #100

Open BSnelling opened 2 years ago

BSnelling commented 2 years ago

An example with setdiff:

julia> d1 = Indices(["A","B","C"]);
julia> c1 = ["B","C","D"];
julia> setdiff(d1, c1)
ERROR: MethodError: no method matching setdiff!(::Indices{String}, ::Vector{String})

Similarly with intersect

julia> intersect(d1, c1)
ERROR: MethodError: no method matching intersect!(::Indices{String}, ::Vector{String})

I would expect these operations to return an Indices{String} with the result, which would be consistent with the behaviour of union

julia> union(d1, c1)
4-element Indices{String}
 "A"
 "B"
 "C"
 "D"
andyferris commented 2 years ago

Right - this does seem like something we can and should fix, using the same dispatch pattern as Base does.