Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJb Evain <jbevain@gmail.com>2009-01-15 20:34:05 +0300
committerJb Evain <jbevain@gmail.com>2009-01-15 20:34:05 +0300
commit61d786b69a08c4366abd7397e413c623fb370254 (patch)
tree1d87c515dcb40f3088e8a883d885f5e61ee9c754 /mcs/class/System.Core/System.Linq/Lookup.cs
parent0e67f5045c8e99f4d92cd193c095868dc40ee867 (diff)
small refactoring
svn path=/trunk/mcs/; revision=123505
Diffstat (limited to 'mcs/class/System.Core/System.Linq/Lookup.cs')
-rw-r--r--mcs/class/System.Core/System.Linq/Lookup.cs29
1 files changed, 14 insertions, 15 deletions
diff --git a/mcs/class/System.Core/System.Linq/Lookup.cs b/mcs/class/System.Core/System.Linq/Lookup.cs
index 03a27fb2c10..0398ad6a53a 100644
--- a/mcs/class/System.Core/System.Linq/Lookup.cs
+++ b/mcs/class/System.Core/System.Linq/Lookup.cs
@@ -4,6 +4,7 @@
// Authors:
// Alejandro Serrano "Serras" (trupill@yahoo.es)
// Marek Safar <marek.safar@gmail.com>
+// Jb Evain <jbevain@novell.com>
//
// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
//
@@ -38,32 +39,30 @@ namespace System.Linq {
Dictionary<TKey, IGrouping<TKey, TElement>> groups;
- internal Lookup (Dictionary<TKey, List<TElement>> groups)
- {
- this.groups = new Dictionary<TKey, IGrouping<TKey, TElement>> (groups.Comparer);
- foreach (KeyValuePair<TKey, List<TElement>> group in groups)
- this.groups.Add (group.Key, new Grouping<TKey, TElement> (group.Key, group.Value));
+ public int Count {
+ get { return groups.Count; }
}
- public IEnumerable<TResult> ApplyResultSelector<TResult> (Func<TKey, IEnumerable<TElement>, TResult> selector)
- {
- foreach (IGrouping<TKey, TElement> group in groups.Values)
- yield return selector (group.Key, group);
+ public IEnumerable<TElement> this [TKey key] {
+ get { return groups [key]; }
}
- public int Count
+ internal Lookup (Dictionary<TKey, List<TElement>> lookup)
{
- get { return groups.Count; }
+ groups = new Dictionary<TKey, IGrouping<TKey, TElement>> (lookup.Comparer);
+ foreach (var slot in lookup)
+ groups.Add (slot.Key, new Grouping<TKey, TElement> (slot.Key, slot.Value));
}
- public bool Contains (TKey key)
+ public IEnumerable<TResult> ApplyResultSelector<TResult> (Func<TKey, IEnumerable<TElement>, TResult> selector)
{
- return groups.ContainsKey (key);
+ foreach (var group in groups.Values)
+ yield return selector (group.Key, group);
}
- public IEnumerable<TElement> this [TKey key]
+ public bool Contains (TKey key)
{
- get { return groups [key]; }
+ return groups.ContainsKey (key);
}
public IEnumerator<IGrouping<TKey, TElement>> GetEnumerator ()