You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now I'm making major revisions to the sorted containers to address several open issues. Here is an issue that I was not planning to address but have stumbled across. The file https://github.com/JuliaCollections/DataStructures.jl/blob/master/src/sorted_dict.jl starts off with a complex sequence of constructors. I'm having trouble understanding the code that attempts to deduce types, and in any case it doesn't work as well as Dict. For example:
julia> w = SortedDict((i=>i^2) for i=1:3)
SortedDict{Any, Any, Base.Order.ForwardOrdering} with 3 entries:
1 => 1
2 => 4
3 => 9
julia> Dict((i=>i^2) for i=1:3)
Dict{Int64, Int64} with 3 entries:
2 => 4
3 => 9
1 => 1
I'm wondering: would it be OK for the constructor SortedDict(kv::Any) to pass kv to collect, and then build the SortedDict from the resulting Vector? The function collect, like Dict, excels at deducing types. The disadvantage is that it is inefficient to copy the data twice, but the documentation can state that the constructor SortedDict{K,V}(kv) is preferred over SortedDict(kv).
The text was updated successfully, but these errors were encountered:
Right now I'm making major revisions to the sorted containers to address several open issues. Here is an issue that I was not planning to address but have stumbled across. The file https://github.com/JuliaCollections/DataStructures.jl/blob/master/src/sorted_dict.jl starts off with a complex sequence of constructors. I'm having trouble understanding the code that attempts to deduce types, and in any case it doesn't work as well as Dict. For example:
I'm wondering: would it be OK for the constructor
SortedDict(kv::Any)
to passkv
tocollect
, and then build the SortedDict from the resulting Vector? The functioncollect
, likeDict
, excels at deducing types. The disadvantage is that it is inefficient to copy the data twice, but the documentation can state that the constructorSortedDict{K,V}(kv)
is preferred overSortedDict(kv)
.The text was updated successfully, but these errors were encountered: