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
I have a need to create a subset of an OrderedSet but it's quite inefficient to do that via iteration, turning a O(N) algorithm into O(N^2):
function Base.getindex(os::OrderedSet, indices::AbstractVector{T}) where {T <: Integer}
new_os = empty(os)
for i in indices
for (j, rf) in enumerate(os)
if j == i
push!(new_os, rf)
end
end
end
return new_os
end
could have been rewritten as
function Base.getindex(os::OrderedSet, indices::AbstractVector{T}) where {T <: Integer}
return getindex.(Ref(os), indices)
end
Any thoughts about making fast lookup available again?
The text was updated successfully, but these errors were encountered:
It's a bit unfortunate that we had to deprecate the fast lookup in
getindex
(ref: JuliaCollections/DataStructures.jl#180)I have a need to create a subset of an
OrderedSet
but it's quite inefficient to do that via iteration, turning a O(N) algorithm into O(N^2):could have been rewritten as
Any thoughts about making fast lookup available again?
The text was updated successfully, but these errors were encountered: