c# - Why doesn't/couldn't IDictionary<TKey,TValue> implement ILookup<TKey,TValue>? -
i suppose doesn't matter, i'm curious.
if difference between dictionary , lookup 1 one-to-one , other one-to-many, wouldn't dictionary more specific/derived version of other?
a lookup collection of key/value pairs key can repeated. dictionary collection of key/value pairs key cannot repeated.
why couldn't idictionary implement ilookup?
i suspect because intention different.
ilookup<t,u>
designed work collection of values. idictionary<t,u>
intended work single value (that could, of course, collection).
while could, of course, have idictionary<t,u>
implementations implement via returning ienumerable<u>
single value, confusing, if "u" collection (ie: list<int>
). in case, ilookup<t,u>.item
return ienumerable<list<int>>
, or should type of check ienumerable<t>
value type, , "flatten" it? either way, it'd confusing, , add questionable value.
Comments
Post a Comment