using System;
using System.Collections;
using System.Collections.Generic;
namespace System.Linq
{
/// Represents a collection of keys each mapped to one or more values.
/// The type of the keys in the .
/// The type of the elements of each value in the .
/// 2
// Token: 0x0200003F RID: 63
public class Lookup : IEnumerable, IEnumerable>, ILookup
{
// Token: 0x06000394 RID: 916 RVA: 0x00010D6C File Offset: 0x0000EF6C
internal Lookup(Dictionary> lookup, IEnumerable nullKeyElements)
{
this.groups = new Dictionary>(lookup.Comparer);
foreach (KeyValuePair> keyValuePair in lookup)
{
this.groups.Add(keyValuePair.Key, new Grouping(keyValuePair.Key, keyValuePair.Value));
}
if (nullKeyElements != null)
{
this.nullGrouping = new Grouping(default(TKey), nullKeyElements);
}
}
/// Returns an enumerator that iterates through the . This class cannot be inherited.
/// An enumerator for the .
// Token: 0x06000395 RID: 917 RVA: 0x00010E20 File Offset: 0x0000F020
IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
/// Gets the number of key/value collection pairs in the .
/// The number of key/value collection pairs in the .
// Token: 0x17000041 RID: 65
// (get) Token: 0x06000396 RID: 918 RVA: 0x00010E28 File Offset: 0x0000F028
public int Count
{
get
{
return (this.nullGrouping != null) ? (this.groups.Count + 1) : this.groups.Count;
}
}
/// Gets the collection of values indexed by the specified key.
/// The collection of values indexed by the specified key.
/// The key of the desired collection of values.
// Token: 0x17000042 RID: 66
public IEnumerable this[TKey key]
{
get
{
if (key == null && this.nullGrouping != null)
{
return this.nullGrouping;
}
IGrouping grouping;
if (key != null && this.groups.TryGetValue(key, out grouping))
{
return grouping;
}
return new TElement[0];
}
}
/// Applies a transform function to each key and its associated values and returns the results.
/// A collection that contains one value for each key/value collection pair in the .
/// A function to project a result value from each key and its associated values.
/// The type of the result values produced by .
/// 2
// Token: 0x06000398 RID: 920 RVA: 0x00010EB0 File Offset: 0x0000F0B0
public IEnumerable ApplyResultSelector(Func, TResult> selector)
{
if (this.nullGrouping != null)
{
yield return selector(this.nullGrouping.Key, this.nullGrouping);
}
foreach (IGrouping group in this.groups.Values)
{
yield return selector(group.Key, group);
}
yield break;
}
/// Determines whether a specified key is in the .
/// true if is in the ; otherwise, false.
/// The key to find in the .
// Token: 0x06000399 RID: 921 RVA: 0x00010EE4 File Offset: 0x0000F0E4
public bool Contains(TKey key)
{
return (key == null) ? (this.nullGrouping != null) : this.groups.ContainsKey(key);
}
/// Returns a generic enumerator that iterates through the .
/// An enumerator for the .
// Token: 0x0600039A RID: 922 RVA: 0x00010F1C File Offset: 0x0000F11C
public IEnumerator> GetEnumerator()
{
if (this.nullGrouping != null)
{
yield return this.nullGrouping;
}
foreach (IGrouping g in this.groups.Values)
{
yield return g;
}
yield break;
}
// Token: 0x040000E9 RID: 233
private IGrouping nullGrouping;
// Token: 0x040000EA RID: 234
private Dictionary> groups;
}
}