Is there some standard KeyValue collection allowing adding by value and retrive by key, not dict?
Something like this
6 Replies
I don't see what that adds over just using a dictionary
Dictionaries Contains(TValue value) is O(n), moreover it allows to specify one object for both key and value
that's why you don't search a dictionary by value, that's not what it's designed to be good at
I mean, in your example it's still looking by key not by value
So I don't understand the ask.
the only real difference here is your collection duplicates the value's key in the value itself
Right, which is just a regular dictionary except there is some limitation requiring the value has a key attached to it.
If you want fast lookup by both keys and by values, use two dictionaries.
One for regular lookup, one for reverse lookup.