6 internal class CacheDict<TKey, TValue>
10 internal readonly
int hash;
12 internal readonly TKey key;
14 internal readonly TValue value;
16 internal Entry(
int hash, TKey key, TValue value)
24 protected readonly
int mask;
26 protected readonly Entry[] entries;
28 internal TValue
this[TKey key]
32 if (TryGetValue(key, out TValue value))
44 internal CacheDict(
int size)
46 int num = AlignSize(size);
48 entries =
new Entry[num];
51 private static int AlignSize(
int size)
62 internal bool TryGetValue(TKey key, out TValue value)
64 int hashCode = key.GetHashCode();
65 int num = hashCode & mask;
67 if (entry !=
null && entry.hash == hashCode && entry.key.Equals(key))
72 value =
default(TValue);
76 internal void Add(TKey key, TValue value)
78 int hashCode = key.GetHashCode();
79 int num = hashCode & mask;
81 if (entry ==
null || entry.hash != hashCode || !entry.key.Equals(key))
83 Volatile.
Write(ref entries[num],
new Entry(hashCode, key, value));
static void Write(ref bool location, bool value)
Writes the specified value to the specified field. On systems that require it, inserts a memory barri...
The exception that is thrown when the key specified for accessing an element in a collection does not...
Contains methods for performing volatile memory operations.
The Add key (the addition key on the numeric keypad).
static bool Read(ref bool location)
Reads the value of the specified field. On systems that require it, inserts a memory barrier that pre...