Why can't / can't IDictionary <TKey, TValue> implement ILookup <TKey, TValue>?

I suppose that doesn't really matter, I'm just curious.

If the difference between dictionary and search is one-on-one and the other is one-to-many, will the dictionary be a more specific / derived version of the other?

A search is a set of key / value pairs where a key can be repeated. A dictionary is a collection of key / value pairs where the key cannot be repeated.

Why was IDictionary unable to implement ILookup?

+3
source share
3 answers

I suspect this is mainly because the intention is different.

ILookup<T,U> . IDictionary<T,U> ( , , ).

, , IDictionary<T,U>, IEnumerable<U> , , "U" ( : List<int>), ILookup<T,U>.Item IEnumerable<List<int>>, IEnumerable<T>, "" ? , .

+4

IDictionary<T,U> ILookup<T,U> IEnumerable. IDictionary<T,U> IEnumerable GetEnumerator(), KeyValuePair<T,U>. ILookup<T,U> IEnumerable GetEnumerator() , IGrouping<T,U>. KeyValuePair<T,U> IGrouping<T,U>, , .

+2

, IDictionary'2 ILookup'2. . ILookup'2. , , , .

+1

Source: https://habr.com/ru/post/1794305/


All Articles