Class NetworkDictionary<TKey, TValue>
- Namespace
- Netick
- Assembly
- Netick.dll
A networked Dictionary<TKey, TValue> collection.
public sealed class NetworkDictionary<TKey, TValue> : NetworkDictionary, INetworkCollection, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable where TKey : unmanaged where TValue : unmanaged
Type Parameters
TKeyTValue
- Inheritance
-
NetworkDictionary<TKey, TValue>
- Implements
-
IEnumerable<KeyValuePair<TKey, TValue>>
- Inherited Members
Constructors
NetworkDictionary(int)
public NetworkDictionary(int capacity)
Parameters
capacityint
Properties
Count
Gets the number of elements contained in the dictionary.
public int Count { get; }
Property Value
this[TKey]
Gets or sets the value associated with the specified key.
public TValue this[TKey key] { get; set; }
Parameters
keyTKeyThe key whose value to get or set.
Property Value
- TValue
The value associated with the specified key.
Exceptions
- KeyNotFoundException
Thrown when the key does not exist in the dictionary.
Methods
Add(TKey, TValue)
Adds the specified key and value to the dictionary.
public bool Add(TKey key, TValue value)
Parameters
keyTKeyThe key of the element to add.
valueTValueThe value of the element to add.
Returns
- bool
true if the key/value pair was added; false if the key already exists or the dictionary is full.
Clear()
Removes all keys and values from the dictionary.
public void Clear()
ContainsKey(TKey)
Determines whether the dictionary contains the specified key.
public bool ContainsKey(TKey key)
Parameters
keyTKeyThe key to locate in the dictionary.
Returns
- bool
true if the dictionary contains an element with the specified key; otherwise, false.
ContainsValue(TValue)
Determines whether the dictionary contains a specific value.
public bool ContainsValue(TValue value)
Parameters
valueTValueThe value to locate in the dictionary.
Returns
- bool
true if the value is found; otherwise, false.
GetEnumerator()
public NetworkDictionary<TKey, TValue>.Enumerator GetEnumerator()
Returns
- NetworkDictionary<TKey, TValue>.Enumerator
InternalInit(INetickNetworkScript, int*, int, int)
public override void InternalInit(INetickNetworkScript beh, int* state, int elementSizeWords, int flags)
Parameters
behINetickNetworkScriptstateint*elementSizeWordsintflagsint
InternalReset()
public override void InternalReset()
Remove(TKey)
Removes the value with the specified key from the dictionary.
public bool Remove(TKey key)
Parameters
keyTKeyThe key of the element to remove.
Returns
- bool
true if the element is successfully removed; otherwise, false.
SetKeyValue(TKey, TValue)
Sets the value associated with the specified key if it exists in the dictionary. If the key is found, updates its value.
public bool SetKeyValue(TKey key, TValue value)
Parameters
keyTKeyvalueTValue
Returns
- bool
true if the key was found and updated; otherwise, false
TryGetValue(TKey, out TValue)
Tries to get the value associated with the specified key.
public bool TryGetValue(TKey key, out TValue value)
Parameters
keyTKeyThe key whose value to get.
valueTValueWhen 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
- bool
true if the key was found; otherwise, false.