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
functiondelete_pair!(d::MultiDict, key, val)
vs =get(d, key, Base.secret_table_token)
if vs !== Base.secret_table_token
filter!(x->x≠val, vs)
endisempty(vs) &&delete!(d, key)
return d
end
Unfortunately, this does a linear scan of the values vector to find the target, which isn't great. But to fix this I guess we'd have to use a different datastructure there, like a Set{V}..
Activity
NHDaly commentedon Aug 17, 2020
Like, maybe something like this?:
Unfortunately, this does a linear scan of the values vector to find the target, which isn't great. But to fix this I guess we'd have to use a different datastructure there, like a Set{V}..
NHDaly commentedon Sep 24, 2020
Indeed, the golang vector-based MultiDict does exactly the above, including the terrible worst-case O(n^2) performance if you delete all pairs from the dict with the same keys, one at a time.
https://github.com/jwangsadinata/go-multimap/blob/c29f3d7f33b68d8bcd82880a558e9f8eed58e2b3/slicemultimap/slicemultimap.go#L76-L88
oxinabox commentedon Sep 24, 2020
I think this makes sense