Show / Hide Table of Contents

Class ThreadSafeDictionary<TKey, TValue>

Inheritance
System.Object
ThreadSafeDictionary<TKey, TValue>
ControllerDictionary<TKey, TValue>
Implements
System.Collections.Generic.IDictionary<TKey, TValue>
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey, TValue>>
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, TValue>>
System.Collections.IEnumerable
System.Collections.IDictionary
System.Collections.ICollection
ISnapshotable<System.Collections.Generic.KeyValuePair<TKey, TValue>>
ISnapshotable
Namespace: Eco.Core.Utils
Assembly: Eco.Core.dll
Syntax
public class ThreadSafeDictionary<TKey, TValue> : Object, IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable, IDictionary, ICollection, ISnapshotable<KeyValuePair<TKey, TValue>>, ISnapshotable
Type Parameters
Name Description
TKey
TValue

Constructors

ThreadSafeDictionary()

Declaration
public ThreadSafeDictionary()

Properties

Count

Declaration
public int Count { get; }
Property Value
Type Description
System.Int32

Entries

Declaration
public IEnumerable<KeyValuePair<TKey, TValue>> Entries { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, TValue>>

IsEmpty

Declaration
public bool IsEmpty { get; }
Property Value
Type Description
System.Boolean

IsFixedSize

Declaration
public bool IsFixedSize { get; }
Property Value
Type Description
System.Boolean

IsReadOnly

Declaration
public bool IsReadOnly { get; }
Property Value
Type Description
System.Boolean

IsSynchronized

Declaration
public bool IsSynchronized { get; }
Property Value
Type Description
System.Boolean

Item[TKey]

Declaration
public virtual TValue this[TKey key] { get; set; }
Parameters
Type Name Description
TKey key
Property Value
Type Description
TValue

Keys

Declaration
public IEnumerable<TKey> Keys { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<TKey>

Snapshot

Declaration
public ImmutableDictionary<TKey, TValue> Snapshot { get; }
Property Value
Type Description
System.Collections.Immutable.ImmutableDictionary<TKey, TValue>

SyncRoot

Declaration
public object SyncRoot { get; }
Property Value
Type Description
System.Object

Values

Declaration
public IEnumerable<TValue> Values { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<TValue>

Methods

Add(TKey, TValue)

Declaration
public virtual void Add(TKey key, TValue value)
Parameters
Type Name Description
TKey key
TValue value

Add(KeyValuePair<TKey, TValue>)

Declaration
public void Add(KeyValuePair<TKey, TValue> pair)
Parameters
Type Name Description
System.Collections.Generic.KeyValuePair<TKey, TValue> pair

AddOrUpdate(TKey, TValue, Func<TKey, TValue, TValue>)

Declaration
public virtual TValue AddOrUpdate(TKey key, TValue addValue, Func<TKey, TValue, TValue> updateValueFactory)
Parameters
Type Name Description
TKey key
TValue addValue
System.Func<TKey, TValue, TValue> updateValueFactory
Returns
Type Description
TValue

AddOrUpdate(TKey, Func<TValue>, Func<TValue, TValue>)

Declaration
public virtual TValue AddOrUpdate(TKey key, Func<TValue> createFunc, Func<TValue, TValue> updateFunc)
Parameters
Type Name Description
TKey key
System.Func<TValue> createFunc
System.Func<TValue, TValue> updateFunc
Returns
Type Description
TValue

AddRange(IEnumerable<KeyValuePair<TKey, TValue>>)

Declaration
public virtual void AddRange(IEnumerable<KeyValuePair<TKey, TValue>> pairs)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, TValue>> pairs

Clear()

Declaration
public virtual void Clear()

Contains(KeyValuePair<TKey, TValue>)

Declaration
public bool Contains(KeyValuePair<TKey, TValue> pair)
Parameters
Type Name Description
System.Collections.Generic.KeyValuePair<TKey, TValue> pair
Returns
Type Description
System.Boolean

ContainsKey(TKey)

Declaration
public bool ContainsKey(TKey key)
Parameters
Type Name Description
TKey key
Returns
Type Description
System.Boolean

ContainsValue(TValue)

Declaration
public bool ContainsValue(TValue value)
Parameters
Type Name Description
TValue value
Returns
Type Description
System.Boolean

CopyTo(Array, Int32)

Declaration
public void CopyTo(Array array, int index)
Parameters
Type Name Description
System.Array array
System.Int32 index

CopyTo(KeyValuePair<TKey, TValue>[], Int32)

Declaration
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
Parameters
Type Name Description
System.Collections.Generic.KeyValuePair<TKey, TValue>[] array
System.Int32 arrayIndex

GetEnumerator()

Declaration
public ImmutableDictionary<TKey, TValue>.Enumerator GetEnumerator()
Returns
Type Description
System.Collections.Immutable.ImmutableDictionary.Enumerator<>

GetOr(TKey, TValue)

Declaration
public TValue GetOr(TKey key, TValue defaultVal)
Parameters
Type Name Description
TKey key
TValue defaultVal
Returns
Type Description
TValue

GetOrAdd(TKey)

Declaration
public TValue GetOrAdd(TKey key)
Parameters
Type Name Description
TKey key
Returns
Type Description
TValue

GetOrAdd(TKey, TValue)

Declaration
public virtual TValue GetOrAdd(TKey key, TValue value)
Parameters
Type Name Description
TKey key
TValue value
Returns
Type Description
TValue

GetOrAdd(TKey, Func<TKey, TValue>)

Declaration
public virtual TValue GetOrAdd(TKey key, Func<TKey, TValue> valueFactory)
Parameters
Type Name Description
TKey key
System.Func<TKey, TValue> valueFactory
Returns
Type Description
TValue

GetOrAdd(TKey, Func<TValue>)

Declaration
public TValue GetOrAdd(TKey key, Func<TValue> createFunc)
Parameters
Type Name Description
TKey key
System.Func<TValue> createFunc
Returns
Type Description
TValue

GetOrDefault(TKey)

Declaration
public TValue GetOrDefault(TKey key)
Parameters
Type Name Description
TKey key
Returns
Type Description
TValue

GetSnapshotAndClear()

Declaration
public virtual IReadOnlyDictionary<TKey, TValue> GetSnapshotAndClear()
Returns
Type Description
System.Collections.Generic.IReadOnlyDictionary<TKey, TValue>

Remove(TKey)

Declaration
public virtual bool Remove(TKey key)
Parameters
Type Name Description
TKey key
Returns
Type Description
System.Boolean

Remove(KeyValuePair<TKey, TValue>)

Removes item from dictionary if it matches both key and value of item.

Declaration
public bool Remove(KeyValuePair<TKey, TValue> item)
Parameters
Type Name Description
System.Collections.Generic.KeyValuePair<TKey, TValue> item
Returns
Type Description
System.Boolean

RemoveRange(IEnumerable<TKey>)

Remove the specified keys from the dictionary. Returns a list of all the removed keys or null if no key was removed.

Declaration
public virtual ImmutableDictionary<TKey, TValue> RemoveRange(IEnumerable<TKey> keys)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<TKey> keys
Returns
Type Description
System.Collections.Immutable.ImmutableDictionary<TKey, TValue>

Set(Dictionary<TKey, TValue>)

Declaration
public virtual void Set(Dictionary<TKey, TValue> val)
Parameters
Type Name Description
System.Collections.Generic.Dictionary<TKey, TValue> val

Set(ImmutableDictionary<TKey, TValue>)

Declaration
public virtual void Set(ImmutableDictionary<TKey, TValue> val)
Parameters
Type Name Description
System.Collections.Immutable.ImmutableDictionary<TKey, TValue> val

SetItem(TKey, TValue)

Declaration
public virtual void SetItem(TKey key, TValue value)
Parameters
Type Name Description
TKey key
TValue value

SetItems(IEnumerable<KeyValuePair<TKey, TValue>>)

Declaration
public virtual void SetItems(IEnumerable<KeyValuePair<TKey, TValue>> items)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, TValue>> items

TryAdd(TKey, TValue)

Declaration
public virtual bool TryAdd(TKey key, TValue value)
Parameters
Type Name Description
TKey key
TValue value
Returns
Type Description
System.Boolean

TryGetKey(TKey, out TKey)

Declaration
public bool TryGetKey(TKey key, out TKey actualKey)
Parameters
Type Name Description
TKey key
TKey actualKey
Returns
Type Description
System.Boolean

TryGetValue(TKey, out TValue)

Declaration
public bool TryGetValue(TKey key, out TValue value)
Parameters
Type Name Description
TKey key
TValue value
Returns
Type Description
System.Boolean

TryRemove(TKey)

Declaration
public bool TryRemove(TKey key)
Parameters
Type Name Description
TKey key
Returns
Type Description
System.Boolean

TryRemove(TKey, out TValue)

Declaration
public virtual bool TryRemove(TKey key, out TValue value)
Parameters
Type Name Description
TKey key
TValue value
Returns
Type Description
System.Boolean

TryRemove(KeyValuePair<TKey, TValue>)

Declaration
public virtual bool TryRemove(KeyValuePair<TKey, TValue> pair)
Parameters
Type Name Description
System.Collections.Generic.KeyValuePair<TKey, TValue> pair
Returns
Type Description
System.Boolean

TryUpdate(TKey, TValue, TValue)

Sets the specified key to newValue if the specified key already is set to comparisonValue.

Declaration
public virtual bool TryUpdate(TKey key, TValue newValue, TValue comparisonValue)
Parameters
Type Name Description
TKey key
TValue newValue
TValue comparisonValue
Returns
Type Description
System.Boolean

True if update succeeds.

Explicit Interface Implementations

ISnapshotable.Snapshot

Declaration
ICollection ISnapshotable.Snapshot { get; }
Returns
Type Description
System.Collections.ICollection

ISnapshotable<KeyValuePair<TKey, TValue>>.Snapshot

Declaration
ICollection<KeyValuePair<TKey, TValue>> ISnapshotable<KeyValuePair<TKey, TValue>>.Snapshot { get; }
Returns
Type Description
System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey, TValue>>

Implements

System.Collections.Generic.IDictionary<, >
System.Collections.Generic.ICollection<>
System.Collections.Generic.IEnumerable<>
System.Collections.IEnumerable
System.Collections.IDictionary
System.Collections.ICollection
ISnapshotable<T>
ISnapshotable

Extension Methods

PropertyChanges.FirePropertyChanged(Object, String)
PropertyChanges.FirePropertyChanged(Object, String, Object, Object)
PropertyChanges.FirePropertyChanged(Object, MemberChangedBeforeAfterEventArgs)
☀
☾
In This Article
Back to top
Copyright (c) Strange Loop Games 2021
☀
☾