11[DebuggerDisplay(
"Count = {Count}")]
12public class ConcurrentDictionary<TKey, TValue> :
IDictionary<TKey, TValue>,
ICollection<KeyValuePair<TKey, TValue>>,
IEnumerable<KeyValuePair<TKey, TValue>>,
IEnumerable,
IDictionary,
ICollection,
IReadOnlyDictionary<TKey, TValue>,
IReadOnlyCollection<KeyValuePair<TKey, TValue>>
where TKey :
notnull
61 if ((uint)num >= (uint)buckets.Length)
88 internal readonly TKey
_key;
132 return ref buckets[(uint)
hashcode % (uint)buckets.Length];
141 return ref buckets[num];
185 public TValue
this[TKey
key]
255 bool IDictionary.IsFixedSize =>
false;
257 bool IDictionary.IsReadOnly =>
false;
292 bool ICollection.IsSynchronized =>
false;
294 object ICollection.SyncRoot
325 return IntPtr.Size == 8;
375 if (
item.Key ==
null)
412 for (
int i = 1; i <
array.Length; i++)
414 array[i] =
new object();
459 if (
item.Key ==
null)
490 value =
default(TValue);
499 node._next =
node2._next;
510 value =
default(TValue);
525 if (
typeof(TKey).IsValueType)
560 value =
default(TValue);
570 if (
typeof(TKey).IsValueType)
604 value =
default(TValue);
752 for (
int i = 0; i < buckets.Length; i++)
765 for (
int i = 0; i < buckets.Length; i++)
778 for (
int i = 0; i < buckets.Length; i++)
828 node2._value =
value;
1135 else if (
default(TValue) !=
null)
1217 for (
int i = 0; i <
tables._countPerLock.Length; i++)
1219 num +=
tables._countPerLock[i];
1255 array =
new object[tables._locks.Length * 2];
1271 while (
node2 !=
null)
1343 for (
int i = 0; i < buckets.Length; i++)
1371 for (
int i = 0; i < buckets.Length; i++)
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
static CDSCollectionETWBCLProvider Log
DictionaryEnumerator(ConcurrentDictionary< TKey, TValue > dictionary)
readonly IEnumerator< KeyValuePair< TKey, TValue > > _enumerator
readonly ConcurrentDictionary< TKey, TValue > _dictionary
Enumerator(ConcurrentDictionary< TKey, TValue > dictionary)
KeyValuePair< TKey, TValue > Current
object IEnumerator. Current
Node(TKey key, TValue value, int hashcode, Node next)
ref Node GetBucket(int hashcode)
Tables(Node[] buckets, object[] locks, int[] countPerLock)
readonly int[] _countPerLock
ref Node GetBucketAndLock(int hashcode, out uint lockNo)
readonly ulong _fastModBucketsMultiplier
static void ThrowKeyNotFoundException(TKey key)
bool TryRemoveInternal(TKey key, [MaybeNullWhen(false)] out TValue value, bool matchValue, TValue oldValue)
void AcquireAllLocks(ref int locksAcquired)
bool ContainsKey(TKey key)
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
TValue AddOrUpdate(TKey key, Func< TKey, TValue > addValueFactory, Func< TKey, TValue, TValue > updateValueFactory)
ConcurrentDictionary(IEqualityComparer< TKey >? comparer)
void CopyToPairs(KeyValuePair< TKey, TValue >[] array, int index)
TValue GetOrAdd(TKey key, TValue value)
TValue AddOrUpdate(TKey key, TValue addValue, Func< TKey, TValue, TValue > updateValueFactory)
bool TryAddInternal(TKey key, int? nullableHashcode, TValue value, bool updateIfExists, bool acquireLock, out TValue resultingValue)
TValue GetOrAdd< TArg >(TKey key, Func< TKey, TArg, TValue > valueFactory, TArg factoryArgument)
readonly IEqualityComparer< TKey > _comparer
readonly bool _growLockArray
bool TryUpdateInternal(TKey key, int? nullableHashcode, TValue newValue, TValue comparisonValue)
IEnumerator< KeyValuePair< TKey, TValue > > GetEnumerator()
ConcurrentDictionary(int concurrencyLevel, IEnumerable< KeyValuePair< TKey, TValue > > collection, IEqualityComparer< TKey >? comparer)
ReadOnlyCollection< TKey > GetKeys()
void CopyToEntries(DictionaryEntry[] array, int index)
static readonly bool s_isValueWriteAtomic
ICollection< TValue > Values
ConcurrentDictionary(IEnumerable< KeyValuePair< TKey, TValue > > collection, IEqualityComparer< TKey >? comparer)
void CopyToObjects(object[] array, int index)
ConcurrentDictionary(int concurrencyLevel, int capacity, IEqualityComparer< TKey >? comparer)
void InitializeFromCollection(IEnumerable< KeyValuePair< TKey, TValue > > collection)
TValue AddOrUpdate< TArg >(TKey key, Func< TKey, TArg, TValue > addValueFactory, Func< TKey, TValue, TArg, TValue > updateValueFactory, TArg factoryArgument)
void GrowTable(Tables tables)
bool TryUpdate(TKey key, TValue newValue, TValue comparisonValue)
ConcurrentDictionary(IEnumerable< KeyValuePair< TKey, TValue > > collection)
bool AreAllBucketsEmpty()
readonly EqualityComparer< TKey > _defaultComparer
ReadOnlyCollection< TValue > GetValues()
bool TryAdd(TKey key, TValue value)
void ReleaseLocks(int fromInclusive, int toExclusive)
static int DefaultConcurrencyLevel
ConcurrentDictionary(int concurrencyLevel, int capacity, bool growLockArray, IEqualityComparer< TKey > comparer)
KeyValuePair< TKey, TValue >[] ToArray()
static bool IsValueWriteAtomic()
bool TryGetValueInternal(TKey key, int hashcode, [MaybeNullWhen(false)] out TValue value)
static void ThrowIfInvalidObjectValue(object value)
ConcurrentDictionary(int concurrencyLevel, int capacity)
void AcquireLocks(int fromInclusive, int toExclusive, ref int locksAcquired)
bool TryRemove(KeyValuePair< TKey, TValue > item)
bool TryRemove(TKey key, [MaybeNullWhen(false)] out TValue value)
TValue GetOrAdd(TKey key, Func< TKey, TValue > valueFactory)
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
bool ICollection< KeyValuePair< TKey, TValue > >. IsReadOnly
ref int GetBucket(uint hashCode)
void Add(TKey key, TValue value)
static uint FastMod(uint value, uint divisor, ulong multiplier)
static ulong GetFastModMultiplier(uint divisor)
static int ProcessorCount
static byte Max(byte val1, byte val2)
static string ConcurrentDictionary_ConcurrencyLevelMustBePositive
static string ConcurrentCollection_SyncRoot_NotSupported
static string ConcurrentDictionary_ArrayIncorrectType
static string ConcurrentDictionary_KeyAlreadyExisted
static string ConcurrentDictionary_TypeOfKeyIncorrect
static string Format(string resourceFormat, object p1)
static string ConcurrentDictionary_ItemKeyIsNull
static string ConcurrentDictionary_SourceContainsDuplicateKeys
static string ConcurrentDictionary_ArrayNotLargeEnough
static string ConcurrentDictionary_CapacityMustNotBeNegative
static string ConcurrentDictionary_IndexIsNegative
static string Arg_KeyNotFoundWithKey
static StringComparer Ordinal
static void Exit(object obj)
static void Enter(object obj)
static bool Read(ref bool location)
static void Write(ref bool location, bool value)
static void ThrowKeyNullException()
static void ThrowOutOfMemoryException()
static void ThrowValueNullException()
static void ThrowArgumentNullException(string name)
static TypeCode GetTypeCode(Type? type)
void CopyTo(Array array, int index)
new IDictionaryEnumerator GetEnumerator()
void Add(object key, object? value)
bool Contains(object key)
IEnumerator GetEnumerator()
int GetHashCode(object obj)