ProtonNet Server 1.0
An Open Solution for all your socket or web api needs.
Loading...
Searching...
No Matches
XmobiTea.Collections.Generic.ThreadSafeDictionary< TKey, TValue > Class Template Reference

Provides a thread-safe dictionary implementation that supports concurrent access to elements in a multi-threaded environment. More...

Inheritance diagram for XmobiTea.Collections.Generic.ThreadSafeDictionary< TKey, TValue >:

Public Member Functions

void Add (TKey key, TValue value)
 Adds the specified key and value to the dictionary.
 
void Add (KeyValuePair< TKey, TValue > item)
 Adds the specified key-value pair to the dictionary.
 
void Clear ()
 Removes all keys and values from the dictionary.
 
bool Contains (KeyValuePair< TKey, TValue > item)
 Determines whether the dictionary contains the specified key-value pair.
 
bool ContainsKey (TKey key)
 Determines whether the dictionary contains the specified key.
 
void CopyTo (KeyValuePair< TKey, TValue >[] array, int arrayIndex)
 Copies the elements of the dictionary to an array, starting at a particular array index.
 
IEnumerator< KeyValuePair< TKey, TValue > > GetEnumerator ()
 Returns an enumerator that iterates through the dictionary.
 
bool Remove (TKey key)
 Removes the value with the specified key from the dictionary.
 
bool Remove (KeyValuePair< TKey, TValue > item)
 Removes the specified key-value pair from the dictionary.
 
bool TryGetValue (TKey key, out TValue value)
 Gets the value associated with the specified key.
 
 ThreadSafeDictionary ()
 Initializes a new instance of the ThreadSafeDictionary<TKey, TValue> class.
 
 ThreadSafeDictionary (int capacity)
 Initializes a new instance of the ThreadSafeDictionary<TKey, TValue> class with the specified capacity.
 
 ThreadSafeDictionary (IEqualityComparer< TKey > comparer)
 Initializes a new instance of the ThreadSafeDictionary<TKey, TValue> class with the specified comparer.
 
 ThreadSafeDictionary (IDictionary< TKey, TValue > dictionary)
 Initializes a new instance of the ThreadSafeDictionary<TKey, TValue> class by copying the elements from the specified dictionary.
 
 ThreadSafeDictionary (int capacity, IEqualityComparer< TKey > comparer)
 Initializes a new instance of the ThreadSafeDictionary<TKey, TValue> class with the specified capacity and comparer.
 
 ThreadSafeDictionary (IDictionary< TKey, TValue > dictionary, IEqualityComparer< TKey > comparer)
 Initializes a new instance of the ThreadSafeDictionary<TKey, TValue> class by copying the elements from the specified dictionary and using the specified comparer.
 

Properties

IDictionary< TKey, TValue > originDict [get]
 Stores the underlying dictionary of key-value pairs.
 
TValue this[TKey key] [get, set]
 Gets or sets the value associated with the specified key.
 
ICollection< TKey > Keys [get]
 Gets a collection containing the keys in the dictionary.
 
ICollection< TValue > Values [get]
 Gets a collection containing the values in the dictionary.
 
int Count [get]
 Gets the number of key/value pairs contained in the dictionary.
 
bool IsReadOnly [get]
 Gets a value indicating whether the dictionary is read-only.
 

Detailed Description

Provides a thread-safe dictionary implementation that supports concurrent access to elements in a multi-threaded environment.

Constructor & Destructor Documentation

◆ ThreadSafeDictionary() [1/5]

Initializes a new instance of the ThreadSafeDictionary<TKey, TValue> class with the specified capacity.

Parameters
capacityThe initial number of elements that the dictionary can contain.

◆ ThreadSafeDictionary() [2/5]

XmobiTea.Collections.Generic.ThreadSafeDictionary< TKey, TValue >.ThreadSafeDictionary ( IEqualityComparer< TKey > comparer)

Initializes a new instance of the ThreadSafeDictionary<TKey, TValue> class with the specified comparer.

Parameters
comparerThe IEqualityComparer<TKey> implementation to use when comparing keys, or null to use the default equality comparer for the type of the key.

◆ ThreadSafeDictionary() [3/5]

XmobiTea.Collections.Generic.ThreadSafeDictionary< TKey, TValue >.ThreadSafeDictionary ( IDictionary< TKey, TValue > dictionary)

Initializes a new instance of the ThreadSafeDictionary<TKey, TValue> class by copying the elements from the specified dictionary.

Parameters
dictionaryThe dictionary whose elements are copied to the new dictionary.

◆ ThreadSafeDictionary() [4/5]

XmobiTea.Collections.Generic.ThreadSafeDictionary< TKey, TValue >.ThreadSafeDictionary ( int capacity,
IEqualityComparer< TKey > comparer )

Initializes a new instance of the ThreadSafeDictionary<TKey, TValue> class with the specified capacity and comparer.

Parameters
capacityThe initial number of elements that the dictionary can contain.
comparerThe IEqualityComparer<TKey> implementation to use when comparing keys, or null to use the default equality comparer for the type of the key.

◆ ThreadSafeDictionary() [5/5]

XmobiTea.Collections.Generic.ThreadSafeDictionary< TKey, TValue >.ThreadSafeDictionary ( IDictionary< TKey, TValue > dictionary,
IEqualityComparer< TKey > comparer )

Initializes a new instance of the ThreadSafeDictionary<TKey, TValue> class by copying the elements from the specified dictionary and using the specified comparer.

Parameters
dictionaryThe dictionary whose elements are copied to the new dictionary.
comparerThe IEqualityComparer<TKey> implementation to use when comparing keys, or null to use the default equality comparer for the type of the key.

Member Function Documentation

◆ Add() [1/2]

void XmobiTea.Collections.Generic.ThreadSafeDictionary< TKey, TValue >.Add ( KeyValuePair< TKey, TValue > item)

Adds the specified key-value pair to the dictionary.

Parameters
itemThe key-value pair to add to the dictionary.

◆ Add() [2/2]

void XmobiTea.Collections.Generic.ThreadSafeDictionary< TKey, TValue >.Add ( TKey key,
TValue value )

Adds the specified key and value to the dictionary.

Parameters
keyThe key of the element to add.
valueThe value of the element to add.

◆ Contains()

bool XmobiTea.Collections.Generic.ThreadSafeDictionary< TKey, TValue >.Contains ( KeyValuePair< TKey, TValue > item)

Determines whether the dictionary contains the specified key-value pair.

Parameters
itemThe key-value pair to locate in the dictionary.
Returns
True if the dictionary contains the specified key-value pair; otherwise, false.

◆ ContainsKey()

bool XmobiTea.Collections.Generic.ThreadSafeDictionary< TKey, TValue >.ContainsKey ( TKey key)

Determines whether the dictionary contains the specified key.

Parameters
keyThe key to locate in the dictionary.
Returns
True if the dictionary contains the specified key; otherwise, false.

◆ CopyTo()

void XmobiTea.Collections.Generic.ThreadSafeDictionary< TKey, TValue >.CopyTo ( KeyValuePair< TKey, TValue >[] array,
int arrayIndex )

Copies the elements of the dictionary to an array, starting at a particular array index.

Parameters
arrayThe one-dimensional array that is the destination of the elements copied from the dictionary.
arrayIndexThe zero-based index in the array at which copying begins.

◆ GetEnumerator()

IEnumerator< KeyValuePair< TKey, TValue > > XmobiTea.Collections.Generic.ThreadSafeDictionary< TKey, TValue >.GetEnumerator ( )

Returns an enumerator that iterates through the dictionary.

Returns
An enumerator that can be used to iterate through the dictionary.

◆ Remove() [1/2]

bool XmobiTea.Collections.Generic.ThreadSafeDictionary< TKey, TValue >.Remove ( KeyValuePair< TKey, TValue > item)

Removes the specified key-value pair from the dictionary.

Parameters
itemThe key-value pair to remove from the dictionary.
Returns
True if the key-value pair is successfully found and removed; otherwise, false.

◆ Remove() [2/2]

bool XmobiTea.Collections.Generic.ThreadSafeDictionary< TKey, TValue >.Remove ( TKey key)

Removes the value with the specified key from the dictionary.

Parameters
keyThe key of the element to remove.
Returns
True if the element is successfully found and removed; otherwise, false.

◆ TryGetValue()

bool XmobiTea.Collections.Generic.ThreadSafeDictionary< TKey, TValue >.TryGetValue ( TKey key,
out TValue value )

Gets the value associated with the specified key.

Parameters
keyThe key whose value to get.
valueWhen 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 value parameter.
Returns
True if the dictionary contains an element with the specified key; otherwise, false.

Property Documentation

◆ this[TKey key]

TValue XmobiTea.Collections.Generic.ThreadSafeDictionary< TKey, TValue >.this[TKey key]
getset

Gets or sets the value associated with the specified key.

Parameters
keyThe key whose value is to be accessed or modified.

The documentation for this class was generated from the following file: