// Token: 0x06006F10 RID: 28432 RVA: 0x0017E114 File Offset: 0x0017C314 internal void Insert(K key, V value) { int num = CerHashtable <K, V> .GetHashCodeHelper(key); if (num < 0) { num = ~num; } K[] keys = this.m_keys; int num2 = num % keys.Length; for (;;) { K k = keys[num2]; if (k == null) { break; } num2++; if (num2 >= keys.Length) { num2 -= keys.Length; } } this.m_count++; this.m_values[num2] = value; Volatile.Write <K>(ref keys[num2], key); }
internal V this[K key] { get { CerHashtable <K, V> .Table table = Volatile.Read <CerHashtable <K, V> .Table>(ref this.m_Table); if (table == null) { return(default(V)); } int num = CerHashtable <K, V> .GetHashCodeHelper(key); if (num < 0) { num = ~num; } K[] kArray = table.m_keys; int index = num % kArray.Length; while (true) { do { K k = Volatile.Read <K>(ref kArray[index]); if ((object)k != null) { if (k.Equals((object)key)) { return(table.m_values[index]); } ++index; } else { goto label_10; } }while (index < kArray.Length); index -= kArray.Length; } label_10: return(default(V)); } set { CerHashtable <K, V> .Table table = this.m_Table; if (table != null) { int newSize = 2 * (table.m_count + 1); if (newSize >= table.m_keys.Length) { this.Rehash(newSize); } } else { this.Rehash(7); } this.m_Table.Insert(key, value); } }
// Token: 0x170009D1 RID: 2513 internal V this[K key] { get { CerHashtable <K, V> .Table table = Volatile.Read <CerHashtable <K, V> .Table>(ref this.m_Table); if (table == null) { return(default(V)); } int num = CerHashtable <K, V> .GetHashCodeHelper(key); if (num < 0) { num = ~num; } K[] keys = table.m_keys; int num2 = num % keys.Length; for (;;) { K k = Volatile.Read <K>(ref keys[num2]); if (k == null) { goto IL_7F; } if (k.Equals(key)) { break; } num2++; if (num2 >= keys.Length) { num2 -= keys.Length; } } return(table.m_values[num2]); IL_7F: return(default(V)); } set { CerHashtable <K, V> .Table table = this.m_Table; if (table != null) { int num = 2 * (table.m_count + 1); if (num >= table.m_keys.Length) { this.Rehash(num); } } else { this.Rehash(7); } this.m_Table.Insert(key, value); } }
internal void Preallocate(int count) { bool tookLock = false; bool flag2 = false; K[] keys = null; V[] values = null; RuntimeHelpers.PrepareConstrainedRegions(); try { Monitor.ReliableEnter(this, ref tookLock); int min = (count + this.m_count) * 2; if (min >= this.m_value.Length) { min = HashHelpers.GetPrime(min); keys = new K[min]; values = new V[min]; for (int i = 0; i < this.m_key.Length; i++) { K key = this.m_key[i]; if (key != null) { int num3 = 0; CerHashtable <K, V> .Insert(keys, values, ref num3, key, this.m_value[i]); } } flag2 = true; } } finally { if (flag2) { this.m_key = keys; this.m_value = values; } if (tookLock) { Monitor.Exit(this); } } }
// Token: 0x06004245 RID: 16965 RVA: 0x000F5B0C File Offset: 0x000F3D0C private void Rehash(int newSize) { CerHashtable <K, V> .Table table = new CerHashtable <K, V> .Table(newSize); CerHashtable <K, V> .Table table2 = this.m_Table; if (table2 != null) { K[] keys = table2.m_keys; V[] values = table2.m_values; for (int i = 0; i < keys.Length; i++) { K k = keys[i]; if (k != null) { table.Insert(k, values[i]); } } } Volatile.Write <CerHashtable <K, V> .Table>(ref this.m_Table, table); }
private void Rehash(int newSize) { CerHashtable <K, V> .Table table1 = new CerHashtable <K, V> .Table(newSize); CerHashtable <K, V> .Table table2 = this.m_Table; if (table2 != null) { K[] kArray = table2.m_keys; V[] vArray = table2.m_values; for (int index = 0; index < kArray.Length; ++index) { K key = kArray[index]; if ((object)key != null) { table1.Insert(key, vArray[index]); } } } Volatile.Write <CerHashtable <K, V> .Table>(ref this.m_Table, table1); }
internal void Insert(K key, V value) { int num = CerHashtable <K, V> .GetHashCodeHelper(key); if (num < 0) { num = ~num; } K[] kArray = this.m_keys; int index = num % kArray.Length; while ((object)kArray[index] != null) { ++index; if (index >= kArray.Length) { index -= kArray.Length; } } this.m_count = this.m_count + 1; this.m_values[index] = value; Volatile.Write <K>(ref kArray[index], key); }
internal V this[K key] { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] get { V local2; bool tookLock = false; RuntimeHelpers.PrepareConstrainedRegions(); try { Monitor.ReliableEnter(this, ref tookLock); int hashCode = key.GetHashCode(); if (hashCode < 0) { hashCode = -hashCode; } int index = hashCode % this.m_key.Length; while (true) { K local = this.m_key[index]; if (local == null) { break; } if (local.Equals(key)) { return(this.m_value[index]); } index++; index = index % this.m_key.Length; } local2 = default(V); } finally { if (tookLock) { Monitor.Exit(this); } } return(local2); } [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] set { bool tookLock = false; RuntimeHelpers.PrepareConstrainedRegions(); try { Monitor.ReliableEnter(this, ref tookLock); CerHashtable <K, V> .Insert(this.m_key, this.m_value, ref this.m_count, key, value); } finally { if (tookLock) { Monitor.Exit(this); } } } }