diff options
Diffstat (limited to 'mcs/class/System.Core/System.Linq/Lookup.cs')
-rw-r--r-- | mcs/class/System.Core/System.Linq/Lookup.cs | 85 |
1 files changed, 43 insertions, 42 deletions
diff --git a/mcs/class/System.Core/System.Linq/Lookup.cs b/mcs/class/System.Core/System.Linq/Lookup.cs index 75ef6de4d82..b3e13a6149e 100644 --- a/mcs/class/System.Core/System.Linq/Lookup.cs +++ b/mcs/class/System.Core/System.Linq/Lookup.cs @@ -32,46 +32,47 @@ using System; using System.Collections; using System.Collections.Generic; -namespace System.Linq -{ - public class Lookup<TKey, TElement> : IEnumerable<IGrouping<TKey, TElement>>, ILookup<TKey, TElement> - { - Dictionary<TKey, IGrouping<TKey, TElement>> groups; - - internal Lookup (Dictionary<TKey, List<TElement>> groups) - { - this.groups = new Dictionary<TKey, IGrouping<TKey, TElement>> (); - foreach (KeyValuePair<TKey, List<TElement>> group in groups) - this.groups.Add (group.Key, new Grouping<TKey, TElement>(group.Key, group.Value)); - } - - public IEnumerable<TResult> ApplyResultSelector<TResult>(Func<TKey, IEnumerable <TElement>, TResult> selector) - { - throw new NotImplementedException (); - } - - public int Count { - get { return groups.Count; } - } - - public bool Contains (TKey key) - { - return groups.ContainsKey (key); - } - - public IEnumerable<TElement> this [TKey key] - { - get { return groups[key]; } - } - - public IEnumerator<IGrouping<TKey, TElement>> GetEnumerator () - { - return groups.Values.GetEnumerator (); - } - - IEnumerator IEnumerable.GetEnumerator () - { - return groups.Values.GetEnumerator (); - } - } +namespace System.Linq { + + class Lookup<TKey, TElement> : IEnumerable<IGrouping<TKey, TElement>>, ILookup<TKey, TElement> { + + Dictionary<TKey, IGrouping<TKey, TElement>> groups; + + internal Lookup (Dictionary<TKey, List<TElement>> groups) + { + this.groups = new Dictionary<TKey, IGrouping<TKey, TElement>> (); + foreach (KeyValuePair<TKey, List<TElement>> group in groups) + this.groups.Add (group.Key, new Grouping<TKey, TElement> (group.Key, group.Value)); + } + + public IEnumerable<TResult> ApplyResultSelector<TResult> (Func<TKey, IEnumerable<TElement>, TResult> selector) + { + throw new NotImplementedException (); + } + + public int Count + { + get { return groups.Count; } + } + + public bool Contains (TKey key) + { + return groups.ContainsKey (key); + } + + public IEnumerable<TElement> this [TKey key] + { + get { return groups [key]; } + } + + public IEnumerator<IGrouping<TKey, TElement>> GetEnumerator () + { + return groups.Values.GetEnumerator (); + } + + IEnumerator IEnumerable.GetEnumerator () + { + return groups.Values.GetEnumerator (); + } + } } |