Files
Dec2017-Script-Dump/mscorlib/System/Collections/Generic/Dictionary.cs
T
2026-06-04 11:42:34 +02:00

1626 lines
70 KiB
C#

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
namespace System.Collections.Generic
{
/// <summary>Represents a collection of keys and values.</summary>
/// <typeparam name="TKey">The type of the keys in the dictionary.</typeparam>
/// <typeparam name="TValue">The type of the values in the dictionary.</typeparam>
/// <filterpriority>1</filterpriority>
// Token: 0x020000FF RID: 255
[DebuggerTypeProxy(typeof(CollectionDebuggerView<, >))]
[DebuggerDisplay("Count={Count}")]
[ComVisible(false)]
[Serializable]
public class Dictionary<TKey, TValue> : IEnumerable, ISerializable, ICollection, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IDictionary<TKey, TValue>, IDictionary, IDeserializationCallback
{
/// <summary>Initializes a new instance of the <see cref="T:System.Collections.Generic.Dictionary`2" /> class that is empty, has the default initial capacity, and uses the default equality comparer for the key type.</summary>
// Token: 0x06000C6F RID: 3183 RVA: 0x00038614 File Offset: 0x00036814
public Dictionary()
{
this.Init(10, null);
}
/// <summary>Initializes a new instance of the <see cref="T:System.Collections.Generic.Dictionary`2" /> class that is empty, has the default initial capacity, and uses the specified <see cref="T:System.Collections.Generic.IEqualityComparer`1" />.</summary>
/// <param name="comparer">The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing keys, or null to use the default <see cref="T:System.Collections.Generic.EqualityComparer`1" /> for the type of the key.</param>
// Token: 0x06000C70 RID: 3184 RVA: 0x00038628 File Offset: 0x00036828
public Dictionary(IEqualityComparer<TKey> comparer)
{
this.Init(10, comparer);
}
/// <summary>Initializes a new instance of the <see cref="T:System.Collections.Generic.Dictionary`2" /> class that contains elements copied from the specified <see cref="T:System.Collections.Generic.IDictionary`2" /> and uses the default equality comparer for the key type.</summary>
/// <param name="dictionary">The <see cref="T:System.Collections.Generic.IDictionary`2" /> whose elements are copied to the new <see cref="T:System.Collections.Generic.Dictionary`2" />.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="dictionary" /> is null.</exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="dictionary" /> contains one or more duplicate keys.</exception>
// Token: 0x06000C71 RID: 3185 RVA: 0x0003863C File Offset: 0x0003683C
public Dictionary(IDictionary<TKey, TValue> dictionary)
: this(dictionary, null)
{
}
/// <summary>Initializes a new instance of the <see cref="T:System.Collections.Generic.Dictionary`2" /> class that is empty, has the specified initial capacity, and uses the default equality comparer for the key type.</summary>
/// <param name="capacity">The initial number of elements that the <see cref="T:System.Collections.Generic.Dictionary`2" /> can contain.</param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="capacity" /> is less than 0.</exception>
// Token: 0x06000C72 RID: 3186 RVA: 0x00038648 File Offset: 0x00036848
public Dictionary(int capacity)
{
this.Init(capacity, null);
}
/// <summary>Initializes a new instance of the <see cref="T:System.Collections.Generic.Dictionary`2" /> class that contains elements copied from the specified <see cref="T:System.Collections.Generic.IDictionary`2" /> and uses the specified <see cref="T:System.Collections.Generic.IEqualityComparer`1" />.</summary>
/// <param name="dictionary">The <see cref="T:System.Collections.Generic.IDictionary`2" /> whose elements are copied to the new <see cref="T:System.Collections.Generic.Dictionary`2" />.</param>
/// <param name="comparer">The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing keys, or null to use the default <see cref="T:System.Collections.Generic.EqualityComparer`1" /> for the type of the key.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="dictionary" /> is null.</exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="dictionary" /> contains one or more duplicate keys.</exception>
// Token: 0x06000C73 RID: 3187 RVA: 0x00038658 File Offset: 0x00036858
public Dictionary(IDictionary<TKey, TValue> dictionary, IEqualityComparer<TKey> comparer)
{
if (dictionary == null)
{
throw new ArgumentNullException("dictionary");
}
int num = dictionary.Count;
this.Init(num, comparer);
foreach (KeyValuePair<TKey, TValue> keyValuePair in dictionary)
{
this.Add(keyValuePair.Key, keyValuePair.Value);
}
}
/// <summary>Initializes a new instance of the <see cref="T:System.Collections.Generic.Dictionary`2" /> class that is empty, has the specified initial capacity, and uses the specified <see cref="T:System.Collections.Generic.IEqualityComparer`1" />.</summary>
/// <param name="capacity">The initial number of elements that the <see cref="T:System.Collections.Generic.Dictionary`2" /> can contain.</param>
/// <param name="comparer">The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> implementation to use when comparing keys, or null to use the default <see cref="T:System.Collections.Generic.EqualityComparer`1" /> for the type of the key.</param>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="capacity" /> is less than 0.</exception>
// Token: 0x06000C74 RID: 3188 RVA: 0x000386EC File Offset: 0x000368EC
public Dictionary(int capacity, IEqualityComparer<TKey> comparer)
{
this.Init(capacity, comparer);
}
/// <summary>Initializes a new instance of the <see cref="T:System.Collections.Generic.Dictionary`2" /> class with serialized data.</summary>
/// <param name="info">A <see cref="T:System.Runtime.Serialization.SerializationInfo" /> object containing the information required to serialize the <see cref="T:System.Collections.Generic.Dictionary`2" />.</param>
/// <param name="context">A <see cref="T:System.Runtime.Serialization.StreamingContext" /> structure containing the source and destination of the serialized stream associated with the <see cref="T:System.Collections.Generic.Dictionary`2" />.</param>
// Token: 0x06000C75 RID: 3189 RVA: 0x000386FC File Offset: 0x000368FC
protected Dictionary(SerializationInfo info, StreamingContext context)
{
this.serialization_info = info;
}
// Token: 0x170001C8 RID: 456
// (get) Token: 0x06000C76 RID: 3190 RVA: 0x0003870C File Offset: 0x0003690C
ICollection<TKey> IDictionary<TKey, TValue>.Keys
{
get
{
return this.Keys;
}
}
// Token: 0x170001C9 RID: 457
// (get) Token: 0x06000C77 RID: 3191 RVA: 0x00038714 File Offset: 0x00036914
ICollection<TValue> IDictionary<TKey, TValue>.Values
{
get
{
return this.Values;
}
}
/// <summary>Gets an <see cref="T:System.Collections.ICollection" /> containing the keys of the <see cref="T:System.Collections.IDictionary" />.</summary>
/// <returns>An <see cref="T:System.Collections.ICollection" /> containing the keys of the <see cref="T:System.Collections.IDictionary" />.</returns>
// Token: 0x170001CA RID: 458
// (get) Token: 0x06000C78 RID: 3192 RVA: 0x0003871C File Offset: 0x0003691C
ICollection IDictionary.Keys
{
get
{
return this.Keys;
}
}
/// <summary>Gets an <see cref="T:System.Collections.ICollection" /> containing the values in the <see cref="T:System.Collections.IDictionary" />.</summary>
/// <returns>An <see cref="T:System.Collections.ICollection" /> containing the values in the <see cref="T:System.Collections.IDictionary" />.</returns>
// Token: 0x170001CB RID: 459
// (get) Token: 0x06000C79 RID: 3193 RVA: 0x00038724 File Offset: 0x00036924
ICollection IDictionary.Values
{
get
{
return this.Values;
}
}
/// <summary>Gets a value indicating whether the <see cref="T:System.Collections.IDictionary" /> has a fixed size.</summary>
/// <returns>true if the <see cref="T:System.Collections.IDictionary" /> has a fixed size; otherwise, false. In the default implementation of <see cref="T:System.Collections.Generic.Dictionary`2" />, this property always returns false.</returns>
// Token: 0x170001CC RID: 460
// (get) Token: 0x06000C7A RID: 3194 RVA: 0x0003872C File Offset: 0x0003692C
bool IDictionary.IsFixedSize
{
get
{
return false;
}
}
/// <summary>Gets a value indicating whether the <see cref="T:System.Collections.IDictionary" /> is read-only.</summary>
/// <returns>true if the <see cref="T:System.Collections.IDictionary" /> is read-only; otherwise, false. In the default implementation of <see cref="T:System.Collections.Generic.Dictionary`2" />, this property always returns false.</returns>
// Token: 0x170001CD RID: 461
// (get) Token: 0x06000C7B RID: 3195 RVA: 0x00038730 File Offset: 0x00036930
bool IDictionary.IsReadOnly
{
get
{
return false;
}
}
/// <summary>Gets or sets the value with the specified key.</summary>
/// <returns>The value associated with the specified key, or null if <paramref name="key" /> is not in the dictionary or <paramref name="key" /> is of a type that is not assignable to the key type <paramref name="TKey" /> of the <see cref="T:System.Collections.Generic.Dictionary`2" />.</returns>
/// <param name="key">The key of the value to get.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="key" /> is null.</exception>
/// <exception cref="T:System.ArgumentException">A value is being assigned, and <paramref name="key" /> is of a type that is not assignable to the key type <paramref name="TKey" /> of the <see cref="T:System.Collections.Generic.Dictionary`2" />.-or-A value is being assigned, and <paramref name="value" /> is of a type that is not assignable to the value type <paramref name="TValue" /> of the <see cref="T:System.Collections.Generic.Dictionary`2" />.</exception>
// Token: 0x170001CE RID: 462
object IDictionary.this[object key]
{
get
{
if (key is TKey && this.ContainsKey((TKey)((object)key)))
{
return this[this.ToTKey(key)];
}
return null;
}
set
{
this[this.ToTKey(key)] = this.ToTValue(value);
}
}
/// <summary>Adds the specified key and value to the dictionary.</summary>
/// <param name="key">The object to use as the key.</param>
/// <param name="value">The object to use as the value.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="key" /> is null.</exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="key" /> is of a type that is not assignable to the key type <paramref name="TKey" /> of the <see cref="T:System.Collections.Generic.Dictionary`2" />.-or-<paramref name="value" /> is of a type that is not assignable to <paramref name="TValue" />, the type of values in the <see cref="T:System.Collections.Generic.Dictionary`2" />.-or-A value with the same key already exists in the <see cref="T:System.Collections.Generic.Dictionary`2" />.</exception>
// Token: 0x06000C7E RID: 3198 RVA: 0x0003878C File Offset: 0x0003698C
void IDictionary.Add(object key, object value)
{
this.Add(this.ToTKey(key), this.ToTValue(value));
}
/// <summary>Determines whether the <see cref="T:System.Collections.IDictionary" /> contains an element with the specified key.</summary>
/// <returns>true if the <see cref="T:System.Collections.IDictionary" /> contains an element with the specified key; otherwise, false.</returns>
/// <param name="key">The key to locate in the <see cref="T:System.Collections.IDictionary" />.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="key" /> is null.</exception>
// Token: 0x06000C7F RID: 3199 RVA: 0x000387A4 File Offset: 0x000369A4
bool IDictionary.Contains(object key)
{
if (key == null)
{
throw new ArgumentNullException("key");
}
return key is TKey && this.ContainsKey((TKey)((object)key));
}
/// <summary>Removes the element with the specified key from the <see cref="T:System.Collections.IDictionary" />.</summary>
/// <param name="key">The key of the element to remove.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="key" /> is null.</exception>
// Token: 0x06000C80 RID: 3200 RVA: 0x000387DC File Offset: 0x000369DC
void IDictionary.Remove(object key)
{
if (key == null)
{
throw new ArgumentNullException("key");
}
if (key is TKey)
{
this.Remove((TKey)((object)key));
}
}
/// <summary>Gets a value indicating whether access to the <see cref="T:System.Collections.ICollection" /> is synchronized (thread safe).</summary>
/// <returns>true if access to the <see cref="T:System.Collections.ICollection" /> is synchronized (thread safe); otherwise, false. In the default implementation of <see cref="T:System.Collections.Generic.Dictionary`2" />, this property always returns false.</returns>
// Token: 0x170001CF RID: 463
// (get) Token: 0x06000C81 RID: 3201 RVA: 0x00038808 File Offset: 0x00036A08
bool ICollection.IsSynchronized
{
get
{
return false;
}
}
/// <summary>Gets an object that can be used to synchronize access to the <see cref="T:System.Collections.ICollection" />.</summary>
/// <returns>An object that can be used to synchronize access to the <see cref="T:System.Collections.ICollection" />. </returns>
// Token: 0x170001D0 RID: 464
// (get) Token: 0x06000C82 RID: 3202 RVA: 0x0003880C File Offset: 0x00036A0C
object ICollection.SyncRoot
{
get
{
return this;
}
}
// Token: 0x170001D1 RID: 465
// (get) Token: 0x06000C83 RID: 3203 RVA: 0x00038810 File Offset: 0x00036A10
bool ICollection<KeyValuePair<TKey, TValue>>.IsReadOnly
{
get
{
return false;
}
}
// Token: 0x06000C84 RID: 3204 RVA: 0x00038814 File Offset: 0x00036A14
void ICollection<KeyValuePair<TKey, TValue>>.Add(KeyValuePair<TKey, TValue> keyValuePair)
{
this.Add(keyValuePair.Key, keyValuePair.Value);
}
// Token: 0x06000C85 RID: 3205 RVA: 0x0003882C File Offset: 0x00036A2C
bool ICollection<KeyValuePair<TKey, TValue>>.Contains(KeyValuePair<TKey, TValue> keyValuePair)
{
return this.ContainsKeyValuePair(keyValuePair);
}
// Token: 0x06000C86 RID: 3206 RVA: 0x00038838 File Offset: 0x00036A38
void ICollection<KeyValuePair<TKey, TValue>>.CopyTo(KeyValuePair<TKey, TValue>[] array, int index)
{
this.CopyTo(array, index);
}
// Token: 0x06000C87 RID: 3207 RVA: 0x00038844 File Offset: 0x00036A44
bool ICollection<KeyValuePair<TKey, TValue>>.Remove(KeyValuePair<TKey, TValue> keyValuePair)
{
return this.ContainsKeyValuePair(keyValuePair) && this.Remove(keyValuePair.Key);
}
/// <summary>Copies the elements of the <see cref="T:System.Collections.Generic.ICollection`1" /> to an array, starting at the specified array index.</summary>
/// <param name="array">The one-dimensional array that is the destination of the elements copied from <see cref="T:System.Collections.Generic.ICollection`1" />. The array must have zero-based indexing.</param>
/// <param name="index">The zero-based index in <paramref name="array" /> at which copying begins.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="array" /> is null.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="index" /> is less than 0.</exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="array" /> is multidimensional.-or-<paramref name="array" /> does not have zero-based indexing.-or-The number of elements in the source <see cref="T:System.Collections.Generic.ICollection`1" /> is greater than the available space from <paramref name="index" /> to the end of the destination <paramref name="array" />.-or-The type of the source <see cref="T:System.Collections.Generic.ICollection`1" /> cannot be cast automatically to the type of the destination <paramref name="array" />.</exception>
// Token: 0x06000C88 RID: 3208 RVA: 0x00038864 File Offset: 0x00036A64
void ICollection.CopyTo(Array array, int index)
{
KeyValuePair<TKey, TValue>[] array2 = array as KeyValuePair<TKey, TValue>[];
if (array2 != null)
{
this.CopyTo(array2, index);
return;
}
this.CopyToCheck(array, index);
DictionaryEntry[] array3 = array as DictionaryEntry[];
if (array3 != null)
{
this.Do_CopyTo<DictionaryEntry, DictionaryEntry>(array3, index, (TKey key, TValue value) => new DictionaryEntry(key, value));
return;
}
this.Do_ICollectionCopyTo<KeyValuePair<TKey, TValue>>(array, index, new Dictionary<TKey, TValue>.Transform<KeyValuePair<TKey, TValue>>(Dictionary<TKey, TValue>.make_pair));
}
/// <summary>Returns an enumerator that iterates through the collection.</summary>
/// <returns>An <see cref="T:System.Collections.IEnumerator" /> that can be used to iterate through the collection.</returns>
// Token: 0x06000C89 RID: 3209 RVA: 0x000388D8 File Offset: 0x00036AD8
IEnumerator IEnumerable.GetEnumerator()
{
return new Dictionary<TKey, TValue>.Enumerator(this);
}
// Token: 0x06000C8A RID: 3210 RVA: 0x000388E8 File Offset: 0x00036AE8
IEnumerator<KeyValuePair<TKey, TValue>> IEnumerable<KeyValuePair<TKey, TValue>>.GetEnumerator()
{
return new Dictionary<TKey, TValue>.Enumerator(this);
}
/// <summary>Returns an <see cref="T:System.Collections.IDictionaryEnumerator" /> for the <see cref="T:System.Collections.IDictionary" />.</summary>
/// <returns>An <see cref="T:System.Collections.IDictionaryEnumerator" /> for the <see cref="T:System.Collections.IDictionary" />.</returns>
// Token: 0x06000C8B RID: 3211 RVA: 0x000388F8 File Offset: 0x00036AF8
IDictionaryEnumerator IDictionary.GetEnumerator()
{
return new Dictionary<TKey, TValue>.ShimEnumerator(this);
}
/// <summary>Gets the number of key/value pairs contained in the <see cref="T:System.Collections.Generic.Dictionary`2" />.</summary>
/// <returns>The number of key/value pairs contained in the <see cref="T:System.Collections.Generic.Dictionary`2" />.</returns>
// Token: 0x170001D2 RID: 466
// (get) Token: 0x06000C8C RID: 3212 RVA: 0x00038900 File Offset: 0x00036B00
public int Count
{
get
{
return this.count;
}
}
/// <summary>Gets or sets the value associated with the specified key.</summary>
/// <returns>The value associated with the specified key. If the specified key is not found, a get operation throws a <see cref="T:System.Collections.Generic.KeyNotFoundException" />, and a set operation creates a new element with the specified key.</returns>
/// <param name="key">The key of the value to get or set.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="key" /> is null.</exception>
/// <exception cref="T:System.Collections.Generic.KeyNotFoundException">The property is retrieved and <paramref name="key" /> does not exist in the collection.</exception>
// Token: 0x170001D3 RID: 467
public TValue this[TKey key]
{
get
{
if (key == null)
{
throw new ArgumentNullException("key");
}
int num = this.hcp.GetHashCode(key) | int.MinValue;
for (int num2 = this.table[(num & int.MaxValue) % this.table.Length] - 1; num2 != -1; num2 = this.linkSlots[num2].Next)
{
if (this.linkSlots[num2].HashCode == num && this.hcp.Equals(this.keySlots[num2], key))
{
return this.valueSlots[num2];
}
}
throw new KeyNotFoundException();
}
set
{
if (key == null)
{
throw new ArgumentNullException("key");
}
int num = this.hcp.GetHashCode(key) | int.MinValue;
int num2 = (num & int.MaxValue) % this.table.Length;
int num3 = this.table[num2] - 1;
int num4 = -1;
if (num3 != -1)
{
while (this.linkSlots[num3].HashCode != num || !this.hcp.Equals(this.keySlots[num3], key))
{
num4 = num3;
num3 = this.linkSlots[num3].Next;
if (num3 == -1)
{
break;
}
}
}
if (num3 == -1)
{
if (++this.count > this.threshold)
{
this.Resize();
num2 = (num & int.MaxValue) % this.table.Length;
}
num3 = this.emptySlot;
if (num3 == -1)
{
num3 = this.touchedSlots++;
}
else
{
this.emptySlot = this.linkSlots[num3].Next;
}
this.linkSlots[num3].Next = this.table[num2] - 1;
this.table[num2] = num3 + 1;
this.linkSlots[num3].HashCode = num;
this.keySlots[num3] = key;
}
else if (num4 != -1)
{
this.linkSlots[num4].Next = this.linkSlots[num3].Next;
this.linkSlots[num3].Next = this.table[num2] - 1;
this.table[num2] = num3 + 1;
}
this.valueSlots[num3] = value;
this.generation++;
}
}
// Token: 0x06000C8F RID: 3215 RVA: 0x00038B9C File Offset: 0x00036D9C
private void Init(int capacity, IEqualityComparer<TKey> hcp)
{
if (capacity < 0)
{
throw new ArgumentOutOfRangeException("capacity");
}
this.hcp = ((hcp == null) ? EqualityComparer<TKey>.Default : hcp);
if (capacity == 0)
{
capacity = 10;
}
capacity = (int)((float)capacity / 0.9f) + 1;
this.InitArrays(capacity);
this.generation = 0;
}
// Token: 0x06000C90 RID: 3216 RVA: 0x00038BFC File Offset: 0x00036DFC
private void InitArrays(int size)
{
this.table = new int[size];
this.linkSlots = new Link[size];
this.emptySlot = -1;
this.keySlots = new TKey[size];
this.valueSlots = new TValue[size];
this.touchedSlots = 0;
this.threshold = (int)((float)this.table.Length * 0.9f);
if (this.threshold == 0 && this.table.Length > 0)
{
this.threshold = 1;
}
}
// Token: 0x06000C91 RID: 3217 RVA: 0x00038C80 File Offset: 0x00036E80
private void CopyToCheck(Array array, int index)
{
if (array == null)
{
throw new ArgumentNullException("array");
}
if (index < 0)
{
throw new ArgumentOutOfRangeException("index");
}
if (index > array.Length)
{
throw new ArgumentException("index larger than largest valid index of array");
}
if (array.Length - index < this.Count)
{
throw new ArgumentException("Destination array cannot hold the requested elements!");
}
}
// Token: 0x06000C92 RID: 3218 RVA: 0x00038CE8 File Offset: 0x00036EE8
private void Do_CopyTo<TRet, TElem>(TElem[] array, int index, Dictionary<TKey, TValue>.Transform<TRet> transform) where TRet : TElem
{
for (int i = 0; i < this.touchedSlots; i++)
{
if ((this.linkSlots[i].HashCode & -2147483648) != 0)
{
array[index++] = (TElem)((object)transform(this.keySlots[i], this.valueSlots[i]));
}
}
}
// Token: 0x06000C93 RID: 3219 RVA: 0x00038D5C File Offset: 0x00036F5C
private static KeyValuePair<TKey, TValue> make_pair(TKey key, TValue value)
{
return new KeyValuePair<TKey, TValue>(key, value);
}
// Token: 0x06000C94 RID: 3220 RVA: 0x00038D68 File Offset: 0x00036F68
private static TKey pick_key(TKey key, TValue value)
{
return key;
}
// Token: 0x06000C95 RID: 3221 RVA: 0x00038D6C File Offset: 0x00036F6C
private static TValue pick_value(TKey key, TValue value)
{
return value;
}
// Token: 0x06000C96 RID: 3222 RVA: 0x00038D70 File Offset: 0x00036F70
private void CopyTo(KeyValuePair<TKey, TValue>[] array, int index)
{
this.CopyToCheck(array, index);
this.Do_CopyTo<KeyValuePair<TKey, TValue>, KeyValuePair<TKey, TValue>>(array, index, new Dictionary<TKey, TValue>.Transform<KeyValuePair<TKey, TValue>>(Dictionary<TKey, TValue>.make_pair));
}
// Token: 0x06000C97 RID: 3223 RVA: 0x00038D9C File Offset: 0x00036F9C
private void Do_ICollectionCopyTo<TRet>(Array array, int index, Dictionary<TKey, TValue>.Transform<TRet> transform)
{
Type typeFromHandle = typeof(TRet);
Type elementType = array.GetType().GetElementType();
try
{
if ((typeFromHandle.IsPrimitive || elementType.IsPrimitive) && !elementType.IsAssignableFrom(typeFromHandle))
{
throw new Exception();
}
this.Do_CopyTo<TRet, object>((object[])array, index, transform);
}
catch (Exception ex)
{
throw new ArgumentException("Cannot copy source collection elements to destination array", "array", ex);
}
}
// Token: 0x06000C98 RID: 3224 RVA: 0x00038E30 File Offset: 0x00037030
private void Resize()
{
int num = Hashtable.ToPrime((this.table.Length << 1) | 1);
int[] array = new int[num];
Link[] array2 = new Link[num];
for (int i = 0; i < this.table.Length; i++)
{
for (int num2 = this.table[i] - 1; num2 != -1; num2 = this.linkSlots[num2].Next)
{
int num3 = (array2[num2].HashCode = this.hcp.GetHashCode(this.keySlots[num2]) | int.MinValue);
int num4 = (num3 & int.MaxValue) % num;
array2[num2].Next = array[num4] - 1;
array[num4] = num2 + 1;
}
}
this.table = array;
this.linkSlots = array2;
TKey[] array3 = new TKey[num];
TValue[] array4 = new TValue[num];
Array.Copy(this.keySlots, 0, array3, 0, this.touchedSlots);
Array.Copy(this.valueSlots, 0, array4, 0, this.touchedSlots);
this.keySlots = array3;
this.valueSlots = array4;
this.threshold = (int)((float)num * 0.9f);
}
/// <summary>Adds the specified key and value to the dictionary.</summary>
/// <param name="key">The key of the element to add.</param>
/// <param name="value">The value of the element to add. The value can be null for reference types.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="key" /> is null.</exception>
/// <exception cref="T:System.ArgumentException">An element with the same key already exists in the <see cref="T:System.Collections.Generic.Dictionary`2" />.</exception>
// Token: 0x06000C99 RID: 3225 RVA: 0x00038F64 File Offset: 0x00037164
public void Add(TKey key, TValue value)
{
if (key == null)
{
throw new ArgumentNullException("key");
}
int num = this.hcp.GetHashCode(key) | int.MinValue;
int num2 = (num & int.MaxValue) % this.table.Length;
int num3;
for (num3 = this.table[num2] - 1; num3 != -1; num3 = this.linkSlots[num3].Next)
{
if (this.linkSlots[num3].HashCode == num && this.hcp.Equals(this.keySlots[num3], key))
{
throw new ArgumentException("An element with the same key already exists in the dictionary.");
}
}
if (++this.count > this.threshold)
{
this.Resize();
num2 = (num & int.MaxValue) % this.table.Length;
}
num3 = this.emptySlot;
if (num3 == -1)
{
num3 = this.touchedSlots++;
}
else
{
this.emptySlot = this.linkSlots[num3].Next;
}
this.linkSlots[num3].HashCode = num;
this.linkSlots[num3].Next = this.table[num2] - 1;
this.table[num2] = num3 + 1;
this.keySlots[num3] = key;
this.valueSlots[num3] = value;
this.generation++;
}
/// <summary>Gets the <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> that is used to determine equality of keys for the dictionary. </summary>
/// <returns>The <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> generic interface implementation that is used to determine equality of keys for the current <see cref="T:System.Collections.Generic.Dictionary`2" /> and to provide hash values for the keys.</returns>
// Token: 0x170001D4 RID: 468
// (get) Token: 0x06000C9A RID: 3226 RVA: 0x000390E4 File Offset: 0x000372E4
public IEqualityComparer<TKey> Comparer
{
get
{
return this.hcp;
}
}
/// <summary>Removes all keys and values from the <see cref="T:System.Collections.Generic.Dictionary`2" />.</summary>
// Token: 0x06000C9B RID: 3227 RVA: 0x000390EC File Offset: 0x000372EC
public void Clear()
{
this.count = 0;
Array.Clear(this.table, 0, this.table.Length);
Array.Clear(this.keySlots, 0, this.keySlots.Length);
Array.Clear(this.valueSlots, 0, this.valueSlots.Length);
Array.Clear(this.linkSlots, 0, this.linkSlots.Length);
this.emptySlot = -1;
this.touchedSlots = 0;
this.generation++;
}
/// <summary>Determines whether the <see cref="T:System.Collections.Generic.Dictionary`2" /> contains the specified key.</summary>
/// <returns>true if the <see cref="T:System.Collections.Generic.Dictionary`2" /> contains an element with the specified key; otherwise, false.</returns>
/// <param name="key">The key to locate in the <see cref="T:System.Collections.Generic.Dictionary`2" />.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="key" /> is null.</exception>
// Token: 0x06000C9C RID: 3228 RVA: 0x0003916C File Offset: 0x0003736C
public bool ContainsKey(TKey key)
{
if (key == null)
{
throw new ArgumentNullException("key");
}
int num = this.hcp.GetHashCode(key) | int.MinValue;
for (int num2 = this.table[(num & int.MaxValue) % this.table.Length] - 1; num2 != -1; num2 = this.linkSlots[num2].Next)
{
if (this.linkSlots[num2].HashCode == num && this.hcp.Equals(this.keySlots[num2], key))
{
return true;
}
}
return false;
}
/// <summary>Determines whether the <see cref="T:System.Collections.Generic.Dictionary`2" /> contains a specific value.</summary>
/// <returns>true if the <see cref="T:System.Collections.Generic.Dictionary`2" /> contains an element with the specified value; otherwise, false.</returns>
/// <param name="value">The value to locate in the <see cref="T:System.Collections.Generic.Dictionary`2" />. The value can be null for reference types.</param>
// Token: 0x06000C9D RID: 3229 RVA: 0x00039214 File Offset: 0x00037414
public bool ContainsValue(TValue value)
{
IEqualityComparer<TValue> @default = EqualityComparer<TValue>.Default;
for (int i = 0; i < this.table.Length; i++)
{
for (int num = this.table[i] - 1; num != -1; num = this.linkSlots[num].Next)
{
if (@default.Equals(this.valueSlots[num], value))
{
return true;
}
}
}
return false;
}
/// <summary>Implements the <see cref="T:System.Runtime.Serialization.ISerializable" /> interface and returns the data needed to serialize the <see cref="T:System.Collections.Generic.Dictionary`2" /> instance.</summary>
/// <param name="info">A <see cref="T:System.Runtime.Serialization.SerializationInfo" /> object that contains the information required to serialize the <see cref="T:System.Collections.Generic.Dictionary`2" /> instance.</param>
/// <param name="context">A <see cref="T:System.Runtime.Serialization.StreamingContext" /> structure that contains the source and destination of the serialized stream associated with the <see cref="T:System.Collections.Generic.Dictionary`2" /> instance.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="info" /> is null.</exception>
// Token: 0x06000C9E RID: 3230 RVA: 0x00039284 File Offset: 0x00037484
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
if (info == null)
{
throw new ArgumentNullException("info");
}
info.AddValue("Version", this.generation);
info.AddValue("Comparer", this.hcp);
KeyValuePair<TKey, TValue>[] array = null;
if (this.count > 0)
{
array = new KeyValuePair<TKey, TValue>[this.count];
this.CopyTo(array, 0);
}
info.AddValue("HashSize", this.table.Length);
info.AddValue("KeyValuePairs", array);
}
/// <summary>Implements the <see cref="T:System.Runtime.Serialization.ISerializable" /> interface and raises the deserialization event when the deserialization is complete.</summary>
/// <param name="sender">The source of the deserialization event.</param>
/// <exception cref="T:System.Runtime.Serialization.SerializationException">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> object associated with the current <see cref="T:System.Collections.Generic.Dictionary`2" /> instance is invalid.</exception>
// Token: 0x06000C9F RID: 3231 RVA: 0x00039308 File Offset: 0x00037508
public virtual void OnDeserialization(object sender)
{
if (this.serialization_info == null)
{
return;
}
this.generation = this.serialization_info.GetInt32("Version");
this.hcp = (IEqualityComparer<TKey>)this.serialization_info.GetValue("Comparer", typeof(IEqualityComparer<TKey>));
int num = this.serialization_info.GetInt32("HashSize");
KeyValuePair<TKey, TValue>[] array = (KeyValuePair<TKey, TValue>[])this.serialization_info.GetValue("KeyValuePairs", typeof(KeyValuePair<TKey, TValue>[]));
if (num < 10)
{
num = 10;
}
this.InitArrays(num);
this.count = 0;
if (array != null)
{
for (int i = 0; i < array.Length; i++)
{
this.Add(array[i].Key, array[i].Value);
}
}
this.generation++;
this.serialization_info = null;
}
/// <summary>Removes the value with the specified key from the <see cref="T:System.Collections.Generic.Dictionary`2" />.</summary>
/// <returns>true if the element is successfully found and removed; otherwise, false. This method returns false if <paramref name="key" /> is not found in the <see cref="T:System.Collections.Generic.Dictionary`2" />.</returns>
/// <param name="key">The key of the element to remove.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="key" /> is null.</exception>
// Token: 0x06000CA0 RID: 3232 RVA: 0x000393F4 File Offset: 0x000375F4
public bool Remove(TKey key)
{
if (key == null)
{
throw new ArgumentNullException("key");
}
int num = this.hcp.GetHashCode(key) | int.MinValue;
int num2 = (num & int.MaxValue) % this.table.Length;
int num3 = this.table[num2] - 1;
if (num3 == -1)
{
return false;
}
int num4 = -1;
while (this.linkSlots[num3].HashCode != num || !this.hcp.Equals(this.keySlots[num3], key))
{
num4 = num3;
num3 = this.linkSlots[num3].Next;
if (num3 == -1)
{
IL_A4:
if (num3 == -1)
{
return false;
}
this.count--;
if (num4 == -1)
{
this.table[num2] = this.linkSlots[num3].Next + 1;
}
else
{
this.linkSlots[num4].Next = this.linkSlots[num3].Next;
}
this.linkSlots[num3].Next = this.emptySlot;
this.emptySlot = num3;
this.linkSlots[num3].HashCode = 0;
this.keySlots[num3] = default(TKey);
this.valueSlots[num3] = default(TValue);
this.generation++;
return true;
}
}
goto IL_A4;
}
/// <summary>Gets the value associated with the specified key.</summary>
/// <returns>true if the <see cref="T:System.Collections.Generic.Dictionary`2" /> contains an element with the specified key; otherwise, false.</returns>
/// <param name="key">The key of the value to get.</param>
/// <param name="value">When this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the <paramref name="value" /> parameter. This parameter is passed uninitialized.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="key" /> is null.</exception>
// Token: 0x06000CA1 RID: 3233 RVA: 0x00039570 File Offset: 0x00037770
public bool TryGetValue(TKey key, out TValue value)
{
if (key == null)
{
throw new ArgumentNullException("key");
}
int num = this.hcp.GetHashCode(key) | int.MinValue;
for (int num2 = this.table[(num & int.MaxValue) % this.table.Length] - 1; num2 != -1; num2 = this.linkSlots[num2].Next)
{
if (this.linkSlots[num2].HashCode == num && this.hcp.Equals(this.keySlots[num2], key))
{
value = this.valueSlots[num2];
return true;
}
}
value = default(TValue);
return false;
}
/// <summary>Gets a collection containing the keys in the <see cref="T:System.Collections.Generic.Dictionary`2" />.</summary>
/// <returns>A <see cref="T:System.Collections.Generic.Dictionary`2.KeyCollection" /> containing the keys in the <see cref="T:System.Collections.Generic.Dictionary`2" />.</returns>
// Token: 0x170001D5 RID: 469
// (get) Token: 0x06000CA2 RID: 3234 RVA: 0x00039638 File Offset: 0x00037838
public Dictionary<TKey, TValue>.KeyCollection Keys
{
get
{
return new Dictionary<TKey, TValue>.KeyCollection(this);
}
}
/// <summary>Gets a collection containing the values in the <see cref="T:System.Collections.Generic.Dictionary`2" />.</summary>
/// <returns>A <see cref="T:System.Collections.Generic.Dictionary`2.ValueCollection" /> containing the values in the <see cref="T:System.Collections.Generic.Dictionary`2" />.</returns>
// Token: 0x170001D6 RID: 470
// (get) Token: 0x06000CA3 RID: 3235 RVA: 0x00039640 File Offset: 0x00037840
public Dictionary<TKey, TValue>.ValueCollection Values
{
get
{
return new Dictionary<TKey, TValue>.ValueCollection(this);
}
}
// Token: 0x06000CA4 RID: 3236 RVA: 0x00039648 File Offset: 0x00037848
private TKey ToTKey(object key)
{
if (key == null)
{
throw new ArgumentNullException("key");
}
if (!(key is TKey))
{
throw new ArgumentException("not of type: " + typeof(TKey).ToString(), "key");
}
return (TKey)((object)key);
}
// Token: 0x06000CA5 RID: 3237 RVA: 0x0003969C File Offset: 0x0003789C
private TValue ToTValue(object value)
{
if (value == null && !typeof(TValue).IsValueType)
{
return default(TValue);
}
if (!(value is TValue))
{
throw new ArgumentException("not of type: " + typeof(TValue).ToString(), "value");
}
return (TValue)((object)value);
}
// Token: 0x06000CA6 RID: 3238 RVA: 0x00039704 File Offset: 0x00037904
private bool ContainsKeyValuePair(KeyValuePair<TKey, TValue> pair)
{
TValue tvalue;
return this.TryGetValue(pair.Key, out tvalue) && EqualityComparer<TValue>.Default.Equals(pair.Value, tvalue);
}
/// <summary>Returns an enumerator that iterates through the <see cref="T:System.Collections.Generic.Dictionary`2" />.</summary>
/// <returns>A <see cref="T:System.Collections.Generic.Dictionary`2.Enumerator" /> structure for the <see cref="T:System.Collections.Generic.Dictionary`2" />.</returns>
// Token: 0x06000CA7 RID: 3239 RVA: 0x0003973C File Offset: 0x0003793C
public Dictionary<TKey, TValue>.Enumerator GetEnumerator()
{
return new Dictionary<TKey, TValue>.Enumerator(this);
}
// Token: 0x04000362 RID: 866
private const int INITIAL_SIZE = 10;
// Token: 0x04000363 RID: 867
private const float DEFAULT_LOAD_FACTOR = 0.9f;
// Token: 0x04000364 RID: 868
private const int NO_SLOT = -1;
// Token: 0x04000365 RID: 869
private const int HASH_FLAG = -2147483648;
// Token: 0x04000366 RID: 870
private int[] table;
// Token: 0x04000367 RID: 871
private Link[] linkSlots;
// Token: 0x04000368 RID: 872
private TKey[] keySlots;
// Token: 0x04000369 RID: 873
private TValue[] valueSlots;
// Token: 0x0400036A RID: 874
private int touchedSlots;
// Token: 0x0400036B RID: 875
private int emptySlot;
// Token: 0x0400036C RID: 876
private int count;
// Token: 0x0400036D RID: 877
private int threshold;
// Token: 0x0400036E RID: 878
private IEqualityComparer<TKey> hcp;
// Token: 0x0400036F RID: 879
private SerializationInfo serialization_info;
// Token: 0x04000370 RID: 880
private int generation;
// Token: 0x02000100 RID: 256
[Serializable]
private class ShimEnumerator : IEnumerator, IDictionaryEnumerator
{
// Token: 0x06000CA9 RID: 3241 RVA: 0x00039758 File Offset: 0x00037958
public ShimEnumerator(Dictionary<TKey, TValue> host)
{
this.host_enumerator = host.GetEnumerator();
}
// Token: 0x06000CAA RID: 3242 RVA: 0x0003976C File Offset: 0x0003796C
public void Dispose()
{
this.host_enumerator.Dispose();
}
// Token: 0x06000CAB RID: 3243 RVA: 0x0003977C File Offset: 0x0003797C
public bool MoveNext()
{
return this.host_enumerator.MoveNext();
}
// Token: 0x170001D7 RID: 471
// (get) Token: 0x06000CAC RID: 3244 RVA: 0x0003978C File Offset: 0x0003798C
public DictionaryEntry Entry
{
get
{
return ((IDictionaryEnumerator)this.host_enumerator).Entry;
}
}
// Token: 0x170001D8 RID: 472
// (get) Token: 0x06000CAD RID: 3245 RVA: 0x000397A0 File Offset: 0x000379A0
public object Key
{
get
{
KeyValuePair<TKey, TValue> keyValuePair = this.host_enumerator.Current;
return keyValuePair.Key;
}
}
// Token: 0x170001D9 RID: 473
// (get) Token: 0x06000CAE RID: 3246 RVA: 0x000397C8 File Offset: 0x000379C8
public object Value
{
get
{
KeyValuePair<TKey, TValue> keyValuePair = this.host_enumerator.Current;
return keyValuePair.Value;
}
}
// Token: 0x170001DA RID: 474
// (get) Token: 0x06000CAF RID: 3247 RVA: 0x000397F0 File Offset: 0x000379F0
public object Current
{
get
{
return this.Entry;
}
}
// Token: 0x06000CB0 RID: 3248 RVA: 0x00039800 File Offset: 0x00037A00
public void Reset()
{
this.host_enumerator.Reset();
}
// Token: 0x04000372 RID: 882
private Dictionary<TKey, TValue>.Enumerator host_enumerator;
}
/// <summary>Enumerates the elements of a <see cref="T:System.Collections.Generic.Dictionary`2" />.</summary>
// Token: 0x02000101 RID: 257
[Serializable]
public struct Enumerator : IEnumerator, IDisposable, IEnumerator<KeyValuePair<TKey, TValue>>, IDictionaryEnumerator
{
// Token: 0x06000CB1 RID: 3249 RVA: 0x00039810 File Offset: 0x00037A10
internal Enumerator(Dictionary<TKey, TValue> dictionary)
{
this.dictionary = dictionary;
this.stamp = dictionary.generation;
}
/// <summary>Gets the element at the current position of the enumerator.</summary>
/// <returns>The element in the collection at the current position of the enumerator, as an <see cref="T:System.Object" />.</returns>
/// <exception cref="T:System.InvalidOperationException">The enumerator is positioned before the first element of the collection or after the last element. </exception>
// Token: 0x170001DB RID: 475
// (get) Token: 0x06000CB2 RID: 3250 RVA: 0x00039828 File Offset: 0x00037A28
object IEnumerator.Current
{
get
{
this.VerifyCurrent();
return this.current;
}
}
/// <summary>Sets the enumerator to its initial position, which is before the first element in the collection.</summary>
/// <exception cref="T:System.InvalidOperationException">The collection was modified after the enumerator was created. </exception>
// Token: 0x06000CB3 RID: 3251 RVA: 0x0003983C File Offset: 0x00037A3C
void IEnumerator.Reset()
{
this.Reset();
}
/// <summary>Gets the element at the current position of the enumerator.</summary>
/// <returns>The element in the dictionary at the current position of the enumerator, as a <see cref="T:System.Collections.DictionaryEntry" />.</returns>
/// <exception cref="T:System.InvalidOperationException">The enumerator is positioned before the first element of the collection or after the last element. </exception>
// Token: 0x170001DC RID: 476
// (get) Token: 0x06000CB4 RID: 3252 RVA: 0x00039844 File Offset: 0x00037A44
DictionaryEntry IDictionaryEnumerator.Entry
{
get
{
this.VerifyCurrent();
return new DictionaryEntry(this.current.Key, this.current.Value);
}
}
/// <summary>Gets the key of the element at the current position of the enumerator.</summary>
/// <returns>The key of the element in the dictionary at the current position of the enumerator.</returns>
/// <exception cref="T:System.InvalidOperationException">The enumerator is positioned before the first element of the collection or after the last element. </exception>
// Token: 0x170001DD RID: 477
// (get) Token: 0x06000CB5 RID: 3253 RVA: 0x0003987C File Offset: 0x00037A7C
object IDictionaryEnumerator.Key
{
get
{
return this.CurrentKey;
}
}
/// <summary>Gets the value of the element at the current position of the enumerator.</summary>
/// <returns>The value of the element in the dictionary at the current position of the enumerator.</returns>
/// <exception cref="T:System.InvalidOperationException">The enumerator is positioned before the first element of the collection or after the last element. </exception>
// Token: 0x170001DE RID: 478
// (get) Token: 0x06000CB6 RID: 3254 RVA: 0x0003988C File Offset: 0x00037A8C
object IDictionaryEnumerator.Value
{
get
{
return this.CurrentValue;
}
}
/// <summary>Advances the enumerator to the next element of the <see cref="T:System.Collections.Generic.Dictionary`2" />.</summary>
/// <returns>true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.</returns>
/// <exception cref="T:System.InvalidOperationException">The collection was modified after the enumerator was created. </exception>
// Token: 0x06000CB7 RID: 3255 RVA: 0x0003989C File Offset: 0x00037A9C
public bool MoveNext()
{
this.VerifyState();
if (this.next < 0)
{
return false;
}
while (this.next < this.dictionary.touchedSlots)
{
int num = this.next++;
if ((this.dictionary.linkSlots[num].HashCode & -2147483648) != 0)
{
this.current = new KeyValuePair<TKey, TValue>(this.dictionary.keySlots[num], this.dictionary.valueSlots[num]);
return true;
}
}
this.next = -1;
return false;
}
/// <summary>Gets the element at the current position of the enumerator.</summary>
/// <returns>The element in the <see cref="T:System.Collections.Generic.Dictionary`2" /> at the current position of the enumerator.</returns>
// Token: 0x170001DF RID: 479
// (get) Token: 0x06000CB8 RID: 3256 RVA: 0x00039944 File Offset: 0x00037B44
public KeyValuePair<TKey, TValue> Current
{
get
{
return this.current;
}
}
// Token: 0x170001E0 RID: 480
// (get) Token: 0x06000CB9 RID: 3257 RVA: 0x0003994C File Offset: 0x00037B4C
internal TKey CurrentKey
{
get
{
this.VerifyCurrent();
return this.current.Key;
}
}
// Token: 0x170001E1 RID: 481
// (get) Token: 0x06000CBA RID: 3258 RVA: 0x00039960 File Offset: 0x00037B60
internal TValue CurrentValue
{
get
{
this.VerifyCurrent();
return this.current.Value;
}
}
// Token: 0x06000CBB RID: 3259 RVA: 0x00039974 File Offset: 0x00037B74
internal void Reset()
{
this.VerifyState();
this.next = 0;
}
// Token: 0x06000CBC RID: 3260 RVA: 0x00039984 File Offset: 0x00037B84
private void VerifyState()
{
if (this.dictionary == null)
{
throw new ObjectDisposedException(null);
}
if (this.dictionary.generation != this.stamp)
{
throw new InvalidOperationException("out of sync");
}
}
// Token: 0x06000CBD RID: 3261 RVA: 0x000399BC File Offset: 0x00037BBC
private void VerifyCurrent()
{
this.VerifyState();
if (this.next <= 0)
{
throw new InvalidOperationException("Current is not valid");
}
}
/// <summary>Releases all resources used by the <see cref="T:System.Collections.Generic.Dictionary`2.Enumerator" />.</summary>
// Token: 0x06000CBE RID: 3262 RVA: 0x000399DC File Offset: 0x00037BDC
public void Dispose()
{
this.dictionary = null;
}
// Token: 0x04000373 RID: 883
private Dictionary<TKey, TValue> dictionary;
// Token: 0x04000374 RID: 884
private int next;
// Token: 0x04000375 RID: 885
private int stamp;
// Token: 0x04000376 RID: 886
internal KeyValuePair<TKey, TValue> current;
}
/// <summary>Represents the collection of keys in a <see cref="T:System.Collections.Generic.Dictionary`2" />. This class cannot be inherited. </summary>
// Token: 0x02000102 RID: 258
[DebuggerDisplay("Count={Count}")]
[DebuggerTypeProxy(typeof(CollectionDebuggerView<, >))]
[Serializable]
public sealed class KeyCollection : IEnumerable, ICollection, ICollection<TKey>, IEnumerable<TKey>
{
/// <summary>Initializes a new instance of the <see cref="T:System.Collections.Generic.Dictionary`2.KeyCollection" /> class that reflects the keys in the specified <see cref="T:System.Collections.Generic.Dictionary`2" />.</summary>
/// <param name="dictionary">The <see cref="T:System.Collections.Generic.Dictionary`2" /> whose keys are reflected in the new <see cref="T:System.Collections.Generic.Dictionary`2.KeyCollection" />.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="dictionary" /> is null.</exception>
// Token: 0x06000CBF RID: 3263 RVA: 0x000399E8 File Offset: 0x00037BE8
public KeyCollection(Dictionary<TKey, TValue> dictionary)
{
if (dictionary == null)
{
throw new ArgumentNullException("dictionary");
}
this.dictionary = dictionary;
}
// Token: 0x06000CC0 RID: 3264 RVA: 0x00039A08 File Offset: 0x00037C08
void ICollection<TKey>.Add(TKey item)
{
throw new NotSupportedException("this is a read-only collection");
}
// Token: 0x06000CC1 RID: 3265 RVA: 0x00039A14 File Offset: 0x00037C14
void ICollection<TKey>.Clear()
{
throw new NotSupportedException("this is a read-only collection");
}
// Token: 0x06000CC2 RID: 3266 RVA: 0x00039A20 File Offset: 0x00037C20
bool ICollection<TKey>.Contains(TKey item)
{
return this.dictionary.ContainsKey(item);
}
// Token: 0x06000CC3 RID: 3267 RVA: 0x00039A30 File Offset: 0x00037C30
bool ICollection<TKey>.Remove(TKey item)
{
throw new NotSupportedException("this is a read-only collection");
}
// Token: 0x06000CC4 RID: 3268 RVA: 0x00039A3C File Offset: 0x00037C3C
IEnumerator<TKey> IEnumerable<TKey>.GetEnumerator()
{
return this.GetEnumerator();
}
/// <summary>Copies the elements of the <see cref="T:System.Collections.ICollection" /> to an <see cref="T:System.Array" />, starting at a particular <see cref="T:System.Array" /> index.</summary>
/// <param name="array">The one-dimensional <see cref="T:System.Array" /> that is the destination of the elements copied from <see cref="T:System.Collections.ICollection" />. The <see cref="T:System.Array" /> must have zero-based indexing.</param>
/// <param name="index">The zero-based index in <paramref name="array" /> at which copying begins.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="array" /> is null.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="index" /> is less than zero.</exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="array" /> is multidimensional.-or-<paramref name="array" /> does not have zero-based indexing.-or-The number of elements in the source <see cref="T:System.Collections.ICollection" /> is greater than the available space from <paramref name="index" /> to the end of the destination <paramref name="array" />.-or-The type of the source <see cref="T:System.Collections.ICollection" /> cannot be cast automatically to the type of the destination <paramref name="array" />.</exception>
// Token: 0x06000CC5 RID: 3269 RVA: 0x00039A4C File Offset: 0x00037C4C
void ICollection.CopyTo(Array array, int index)
{
TKey[] array2 = array as TKey[];
if (array2 != null)
{
this.CopyTo(array2, index);
return;
}
this.dictionary.CopyToCheck(array, index);
this.dictionary.Do_ICollectionCopyTo<TKey>(array, index, new Dictionary<TKey, TValue>.Transform<TKey>(Dictionary<TKey, TValue>.pick_key));
}
/// <summary>Returns an enumerator that iterates through a collection.</summary>
/// <returns>An <see cref="T:System.Collections.IEnumerator" /> that can be used to iterate through the collection.</returns>
// Token: 0x06000CC6 RID: 3270 RVA: 0x00039A98 File Offset: 0x00037C98
IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
// Token: 0x170001E2 RID: 482
// (get) Token: 0x06000CC7 RID: 3271 RVA: 0x00039AA8 File Offset: 0x00037CA8
bool ICollection<TKey>.IsReadOnly
{
get
{
return true;
}
}
/// <summary>Gets a value indicating whether access to the <see cref="T:System.Collections.ICollection" /> is synchronized (thread safe).</summary>
/// <returns>true if access to the <see cref="T:System.Collections.ICollection" /> is synchronized (thread safe); otherwise, false. In the default implementation of <see cref="T:System.Collections.Generic.Dictionary`2.KeyCollection" />, this property always returns false.</returns>
// Token: 0x170001E3 RID: 483
// (get) Token: 0x06000CC8 RID: 3272 RVA: 0x00039AAC File Offset: 0x00037CAC
bool ICollection.IsSynchronized
{
get
{
return false;
}
}
/// <summary>Gets an object that can be used to synchronize access to the <see cref="T:System.Collections.ICollection" />.</summary>
/// <returns>An object that can be used to synchronize access to the <see cref="T:System.Collections.ICollection" />. In the default implementation of <see cref="T:System.Collections.Generic.Dictionary`2.KeyCollection" />, this property always returns the current instance.</returns>
// Token: 0x170001E4 RID: 484
// (get) Token: 0x06000CC9 RID: 3273 RVA: 0x00039AB0 File Offset: 0x00037CB0
object ICollection.SyncRoot
{
get
{
return ((ICollection)this.dictionary).SyncRoot;
}
}
/// <summary>Copies the <see cref="T:System.Collections.Generic.Dictionary`2.KeyCollection" /> elements to an existing one-dimensional <see cref="T:System.Array" />, starting at the specified array index.</summary>
/// <param name="array">The one-dimensional <see cref="T:System.Array" /> that is the destination of the elements copied from <see cref="T:System.Collections.Generic.Dictionary`2.KeyCollection" />. The <see cref="T:System.Array" /> must have zero-based indexing.</param>
/// <param name="index">The zero-based index in <paramref name="array" /> at which copying begins.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="array" /> is null. </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="index" /> is less than zero.</exception>
/// <exception cref="T:System.ArgumentException">The number of elements in the source <see cref="T:System.Collections.Generic.Dictionary`2.KeyCollection" /> is greater than the available space from <paramref name="index" /> to the end of the destination <paramref name="array" />.</exception>
// Token: 0x06000CCA RID: 3274 RVA: 0x00039AC0 File Offset: 0x00037CC0
public void CopyTo(TKey[] array, int index)
{
this.dictionary.CopyToCheck(array, index);
this.dictionary.Do_CopyTo<TKey, TKey>(array, index, new Dictionary<TKey, TValue>.Transform<TKey>(Dictionary<TKey, TValue>.pick_key));
}
/// <summary>Returns an enumerator that iterates through the <see cref="T:System.Collections.Generic.Dictionary`2.KeyCollection" />.</summary>
/// <returns>A <see cref="T:System.Collections.Generic.Dictionary`2.KeyCollection.Enumerator" /> for the <see cref="T:System.Collections.Generic.Dictionary`2.KeyCollection" />.</returns>
// Token: 0x06000CCB RID: 3275 RVA: 0x00039AF4 File Offset: 0x00037CF4
public Dictionary<TKey, TValue>.KeyCollection.Enumerator GetEnumerator()
{
return new Dictionary<TKey, TValue>.KeyCollection.Enumerator(this.dictionary);
}
/// <summary>Gets the number of elements contained in the <see cref="T:System.Collections.Generic.Dictionary`2.KeyCollection" />.</summary>
/// <returns>The number of elements contained in the <see cref="T:System.Collections.Generic.Dictionary`2.KeyCollection" />.Retrieving the value of this property is an O(1) operation.</returns>
// Token: 0x170001E5 RID: 485
// (get) Token: 0x06000CCC RID: 3276 RVA: 0x00039B04 File Offset: 0x00037D04
public int Count
{
get
{
return this.dictionary.Count;
}
}
// Token: 0x04000377 RID: 887
private Dictionary<TKey, TValue> dictionary;
/// <summary>Enumerates the elements of a <see cref="T:System.Collections.Generic.Dictionary`2.KeyCollection" />.</summary>
// Token: 0x02000103 RID: 259
[Serializable]
public struct Enumerator : IEnumerator, IDisposable, IEnumerator<TKey>
{
// Token: 0x06000CCD RID: 3277 RVA: 0x00039B14 File Offset: 0x00037D14
internal Enumerator(Dictionary<TKey, TValue> host)
{
this.host_enumerator = host.GetEnumerator();
}
/// <summary>Gets the element at the current position of the enumerator.</summary>
/// <returns>The element in the collection at the current position of the enumerator.</returns>
/// <exception cref="T:System.InvalidOperationException">The enumerator is positioned before the first element of the collection or after the last element. </exception>
// Token: 0x170001E6 RID: 486
// (get) Token: 0x06000CCE RID: 3278 RVA: 0x00039B24 File Offset: 0x00037D24
object IEnumerator.Current
{
get
{
return this.host_enumerator.CurrentKey;
}
}
/// <summary>Sets the enumerator to its initial position, which is before the first element in the collection.</summary>
/// <exception cref="T:System.InvalidOperationException">The collection was modified after the enumerator was created. </exception>
// Token: 0x06000CCF RID: 3279 RVA: 0x00039B38 File Offset: 0x00037D38
void IEnumerator.Reset()
{
this.host_enumerator.Reset();
}
/// <summary>Releases all resources used by the <see cref="T:System.Collections.Generic.Dictionary`2.KeyCollection.Enumerator" />.</summary>
// Token: 0x06000CD0 RID: 3280 RVA: 0x00039B48 File Offset: 0x00037D48
public void Dispose()
{
this.host_enumerator.Dispose();
}
/// <summary>Advances the enumerator to the next element of the <see cref="T:System.Collections.Generic.Dictionary`2.KeyCollection" />.</summary>
/// <returns>true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.</returns>
/// <exception cref="T:System.InvalidOperationException">The collection was modified after the enumerator was created. </exception>
// Token: 0x06000CD1 RID: 3281 RVA: 0x00039B58 File Offset: 0x00037D58
public bool MoveNext()
{
return this.host_enumerator.MoveNext();
}
/// <summary>Gets the element at the current position of the enumerator.</summary>
/// <returns>The element in the <see cref="T:System.Collections.Generic.Dictionary`2.KeyCollection" /> at the current position of the enumerator.</returns>
// Token: 0x170001E7 RID: 487
// (get) Token: 0x06000CD2 RID: 3282 RVA: 0x00039B68 File Offset: 0x00037D68
public TKey Current
{
get
{
return this.host_enumerator.current.Key;
}
}
// Token: 0x04000378 RID: 888
private Dictionary<TKey, TValue>.Enumerator host_enumerator;
}
}
/// <summary>Represents the collection of values in a <see cref="T:System.Collections.Generic.Dictionary`2" />. This class cannot be inherited. </summary>
// Token: 0x02000104 RID: 260
[DebuggerTypeProxy(typeof(CollectionDebuggerView<, >))]
[DebuggerDisplay("Count={Count}")]
[Serializable]
public sealed class ValueCollection : IEnumerable, ICollection, ICollection<TValue>, IEnumerable<TValue>
{
/// <summary>Initializes a new instance of the <see cref="T:System.Collections.Generic.Dictionary`2.ValueCollection" /> class that reflects the values in the specified <see cref="T:System.Collections.Generic.Dictionary`2" />.</summary>
/// <param name="dictionary">The <see cref="T:System.Collections.Generic.Dictionary`2" /> whose values are reflected in the new <see cref="T:System.Collections.Generic.Dictionary`2.ValueCollection" />.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="dictionary" /> is null.</exception>
// Token: 0x06000CD3 RID: 3283 RVA: 0x00039B7C File Offset: 0x00037D7C
public ValueCollection(Dictionary<TKey, TValue> dictionary)
{
if (dictionary == null)
{
throw new ArgumentNullException("dictionary");
}
this.dictionary = dictionary;
}
// Token: 0x06000CD4 RID: 3284 RVA: 0x00039B9C File Offset: 0x00037D9C
void ICollection<TValue>.Add(TValue item)
{
throw new NotSupportedException("this is a read-only collection");
}
// Token: 0x06000CD5 RID: 3285 RVA: 0x00039BA8 File Offset: 0x00037DA8
void ICollection<TValue>.Clear()
{
throw new NotSupportedException("this is a read-only collection");
}
// Token: 0x06000CD6 RID: 3286 RVA: 0x00039BB4 File Offset: 0x00037DB4
bool ICollection<TValue>.Contains(TValue item)
{
return this.dictionary.ContainsValue(item);
}
// Token: 0x06000CD7 RID: 3287 RVA: 0x00039BC4 File Offset: 0x00037DC4
bool ICollection<TValue>.Remove(TValue item)
{
throw new NotSupportedException("this is a read-only collection");
}
// Token: 0x06000CD8 RID: 3288 RVA: 0x00039BD0 File Offset: 0x00037DD0
IEnumerator<TValue> IEnumerable<TValue>.GetEnumerator()
{
return this.GetEnumerator();
}
/// <summary>Copies the elements of the <see cref="T:System.Collections.ICollection" /> to an <see cref="T:System.Array" />, starting at a particular <see cref="T:System.Array" /> index.</summary>
/// <param name="array">The one-dimensional <see cref="T:System.Array" /> that is the destination of the elements copied from <see cref="T:System.Collections.ICollection" />. The <see cref="T:System.Array" /> must have zero-based indexing.</param>
/// <param name="index">The zero-based index in <paramref name="array" /> at which copying begins.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="array" /> is null.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="index" /> is less than zero.</exception>
/// <exception cref="T:System.ArgumentException">
/// <paramref name="array" /> is multidimensional.-or-<paramref name="array" /> does not have zero-based indexing.-or-The number of elements in the source <see cref="T:System.Collections.ICollection" /> is greater than the available space from <paramref name="index" /> to the end of the destination <paramref name="array" />.-or-The type of the source <see cref="T:System.Collections.ICollection" /> cannot be cast automatically to the type of the destination <paramref name="array" />.</exception>
// Token: 0x06000CD9 RID: 3289 RVA: 0x00039BE0 File Offset: 0x00037DE0
void ICollection.CopyTo(Array array, int index)
{
TValue[] array2 = array as TValue[];
if (array2 != null)
{
this.CopyTo(array2, index);
return;
}
this.dictionary.CopyToCheck(array, index);
this.dictionary.Do_ICollectionCopyTo<TValue>(array, index, new Dictionary<TKey, TValue>.Transform<TValue>(Dictionary<TKey, TValue>.pick_value));
}
/// <summary>Returns an enumerator that iterates through a collection.</summary>
/// <returns>An <see cref="T:System.Collections.IEnumerator" /> that can be used to iterate through the collection.</returns>
// Token: 0x06000CDA RID: 3290 RVA: 0x00039C2C File Offset: 0x00037E2C
IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
// Token: 0x170001E8 RID: 488
// (get) Token: 0x06000CDB RID: 3291 RVA: 0x00039C3C File Offset: 0x00037E3C
bool ICollection<TValue>.IsReadOnly
{
get
{
return true;
}
}
/// <summary>Gets a value indicating whether access to the <see cref="T:System.Collections.ICollection" /> is synchronized (thread safe).</summary>
/// <returns>true if access to the <see cref="T:System.Collections.ICollection" /> is synchronized (thread safe); otherwise, false. In the default implementation of <see cref="T:System.Collections.Generic.Dictionary`2.ValueCollection" />, this property always returns false.</returns>
// Token: 0x170001E9 RID: 489
// (get) Token: 0x06000CDC RID: 3292 RVA: 0x00039C40 File Offset: 0x00037E40
bool ICollection.IsSynchronized
{
get
{
return false;
}
}
/// <summary>Gets an object that can be used to synchronize access to the <see cref="T:System.Collections.ICollection" />.</summary>
/// <returns>An object that can be used to synchronize access to the <see cref="T:System.Collections.ICollection" />. In the default implementation of <see cref="T:System.Collections.Generic.Dictionary`2.ValueCollection" />, this property always returns the current instance.</returns>
// Token: 0x170001EA RID: 490
// (get) Token: 0x06000CDD RID: 3293 RVA: 0x00039C44 File Offset: 0x00037E44
object ICollection.SyncRoot
{
get
{
return ((ICollection)this.dictionary).SyncRoot;
}
}
/// <summary>Copies the <see cref="T:System.Collections.Generic.Dictionary`2.ValueCollection" /> elements to an existing one-dimensional <see cref="T:System.Array" />, starting at the specified array index.</summary>
/// <param name="array">The one-dimensional <see cref="T:System.Array" /> that is the destination of the elements copied from <see cref="T:System.Collections.Generic.Dictionary`2.ValueCollection" />. The <see cref="T:System.Array" /> must have zero-based indexing.</param>
/// <param name="index">The zero-based index in <paramref name="array" /> at which copying begins.</param>
/// <exception cref="T:System.ArgumentNullException">
/// <paramref name="array" /> is null.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="index" /> is less than zero.</exception>
/// <exception cref="T:System.ArgumentException">The number of elements in the source <see cref="T:System.Collections.Generic.Dictionary`2.ValueCollection" /> is greater than the available space from <paramref name="index" /> to the end of the destination <paramref name="array" />.</exception>
// Token: 0x06000CDE RID: 3294 RVA: 0x00039C54 File Offset: 0x00037E54
public void CopyTo(TValue[] array, int index)
{
this.dictionary.CopyToCheck(array, index);
this.dictionary.Do_CopyTo<TValue, TValue>(array, index, new Dictionary<TKey, TValue>.Transform<TValue>(Dictionary<TKey, TValue>.pick_value));
}
/// <summary>Returns an enumerator that iterates through the <see cref="T:System.Collections.Generic.Dictionary`2.ValueCollection" />.</summary>
/// <returns>A <see cref="T:System.Collections.Generic.Dictionary`2.ValueCollection.Enumerator" /> for the <see cref="T:System.Collections.Generic.Dictionary`2.ValueCollection" />.</returns>
// Token: 0x06000CDF RID: 3295 RVA: 0x00039C88 File Offset: 0x00037E88
public Dictionary<TKey, TValue>.ValueCollection.Enumerator GetEnumerator()
{
return new Dictionary<TKey, TValue>.ValueCollection.Enumerator(this.dictionary);
}
/// <summary>Gets the number of elements contained in the <see cref="T:System.Collections.Generic.Dictionary`2.ValueCollection" />.</summary>
/// <returns>The number of elements contained in the <see cref="T:System.Collections.Generic.Dictionary`2.ValueCollection" />.</returns>
// Token: 0x170001EB RID: 491
// (get) Token: 0x06000CE0 RID: 3296 RVA: 0x00039C98 File Offset: 0x00037E98
public int Count
{
get
{
return this.dictionary.Count;
}
}
// Token: 0x04000379 RID: 889
private Dictionary<TKey, TValue> dictionary;
/// <summary>Enumerates the elements of a <see cref="T:System.Collections.Generic.Dictionary`2.ValueCollection" />.</summary>
// Token: 0x02000105 RID: 261
[Serializable]
public struct Enumerator : IEnumerator, IDisposable, IEnumerator<TValue>
{
// Token: 0x06000CE1 RID: 3297 RVA: 0x00039CA8 File Offset: 0x00037EA8
internal Enumerator(Dictionary<TKey, TValue> host)
{
this.host_enumerator = host.GetEnumerator();
}
/// <summary>Gets the element at the current position of the enumerator.</summary>
/// <returns>The element in the collection at the current position of the enumerator.</returns>
/// <exception cref="T:System.InvalidOperationException">The enumerator is positioned before the first element of the collection or after the last element. </exception>
// Token: 0x170001EC RID: 492
// (get) Token: 0x06000CE2 RID: 3298 RVA: 0x00039CB8 File Offset: 0x00037EB8
object IEnumerator.Current
{
get
{
return this.host_enumerator.CurrentValue;
}
}
/// <summary>Sets the enumerator to its initial position, which is before the first element in the collection.</summary>
/// <exception cref="T:System.InvalidOperationException">The collection was modified after the enumerator was created. </exception>
// Token: 0x06000CE3 RID: 3299 RVA: 0x00039CCC File Offset: 0x00037ECC
void IEnumerator.Reset()
{
this.host_enumerator.Reset();
}
/// <summary>Releases all resources used by the <see cref="T:System.Collections.Generic.Dictionary`2.ValueCollection.Enumerator" />.</summary>
// Token: 0x06000CE4 RID: 3300 RVA: 0x00039CDC File Offset: 0x00037EDC
public void Dispose()
{
this.host_enumerator.Dispose();
}
/// <summary>Advances the enumerator to the next element of the <see cref="T:System.Collections.Generic.Dictionary`2.ValueCollection" />.</summary>
/// <returns>true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.</returns>
/// <exception cref="T:System.InvalidOperationException">The collection was modified after the enumerator was created. </exception>
// Token: 0x06000CE5 RID: 3301 RVA: 0x00039CEC File Offset: 0x00037EEC
public bool MoveNext()
{
return this.host_enumerator.MoveNext();
}
/// <summary>Gets the element at the current position of the enumerator.</summary>
/// <returns>The element in the <see cref="T:System.Collections.Generic.Dictionary`2.ValueCollection" /> at the current position of the enumerator.</returns>
// Token: 0x170001ED RID: 493
// (get) Token: 0x06000CE6 RID: 3302 RVA: 0x00039CFC File Offset: 0x00037EFC
public TValue Current
{
get
{
return this.host_enumerator.current.Value;
}
}
// Token: 0x0400037A RID: 890
private Dictionary<TKey, TValue>.Enumerator host_enumerator;
}
}
// Token: 0x020006C6 RID: 1734
// (Invoke) Token: 0x060041A0 RID: 16800
private delegate TRet Transform<TRet>(TKey key, TValue value);
}
}