internal static NullDictionary <TKey, IReadOnlyList <TSource> > ToGroupedNullDictionary <TSource, TKey>(this IEnumerable <TSource> Source, Func <TSource, TKey> KeySelector) { var dictionary = new NullDictionary <TKey, IReadOnlyList <TSource> >(); foreach (var item in Source.GroupBy(KeySelector)) { dictionary.Add(item.Key, item.ToList().AsReadOnly()); } return(dictionary); }
internal static NullDictionary <TKey, TSource> ToNullDictionary <TSource, TKey>(this IEnumerable <TSource> Source, Func <TSource, TKey> KeySelector) { var dictionary = new NullDictionary <TKey, TSource>(); foreach (var item in Source) { dictionary.Add(KeySelector(item), item); } return(dictionary); }
internal static NullDictionary <TKey, int> ToIndexNullDictionary <TSource, TKey>(this IList <TSource> Source, Func <TSource, TKey> KeySelector) { NullDictionary <TKey, int> dictionary = new NullDictionary <TKey, int>(Source.Count); for (int i = 0; i < Source.Count; i++) { dictionary.Add(KeySelector(Source[i]), i); } return(dictionary); }