Fusion type for networking Dictionaries. Maximum capacity is fixed, and is set with the CapacityAttribute.
More...
Inherits IEnumerable< KeyValuePair< K, V > >, and INetworkDictionary.
Classes | |
struct | Enumerator |
Enumerator for NetworkDictionary. More... | |
Public Member Functions | |
bool | Add (K key, V value) |
Adds a new key value pair to the Dictionary. If the key already exists, will return false. | |
void INetworkDictionary. | Add (object item) |
Adds an item to the networked dictionary. | |
void | Clear () |
Remove all entries from the Dictionary, and clear backing memory. | |
void | ClrEntry (int entry) |
bool | ContainsKey (K key) |
Returns true if the Dictionary contains an entry for the given key. | |
bool | ContainsValue (V value, IEqualityComparer< V > equalityComparer=null) |
Returns true if the Dictionary contains an entry value which compares as equal to given value. | |
int | Find (K key) |
V | Get (K key) |
Returns the value for the given key. Will throw an error if the key is not found. | |
uint | GetBucketFromHashCode (int hash) |
Enumerator | GetEnumerator () |
Returns an enumerator that iterates through the NetworkDictionary. | |
IEnumerator< KeyValuePair< K, V > > IEnumerable< KeyValuePair< K, V > >. | GetEnumerator () |
IEnumerator IEnumerable. | GetEnumerator () |
K | GetKey (int entry) |
int | GetKeyHashCode (K key) |
int | GetNxt (int entry) |
V | GetVal (int entry) |
int | Insert (K key, V val) |
NetworkDictionary (int *data, int capacity, IElementReaderWriter< K > keyReaderWriter, IElementReaderWriter< V > valReaderWriter) | |
Initializes a new instance of the NetworkDictionary struct with the specified data, capacity, and reader/writers. | |
bool | Remove (K key) |
Remove entry from Dictionary. | |
bool | Remove (K key, out V value) |
Removes entry from Dictionary. If successful (key existed), returns true and the value of removed item. | |
V | Set (K key, V value) |
Sets the value for the given key. Will add a new key if the key does not already exist. | |
void | SetKey (int entry, K key) |
void | SetNxt (int entry, int next) |
void | SetVal (int entry, V val) |
NetworkDictionaryReadOnly< K, V > | ToReadOnly () |
Converts the current NetworkDictionary to a read-only version. | |
bool | TryGet (K key, out V value) |
Attempts to get the value for a given key. If found, returns true. | |
void | Add (object item) |
Adds an item to the networked dictionary. | |
Static Public Member Functions | |
static implicit | operator NetworkDictionaryReadOnly< K, V > (NetworkDictionary< K, V > value) |
Converts the current NetworkDictionary to a read-only version. | |
Public Attributes | |
int | _bucketsOffset |
int | _capacity |
int * | _data |
int | _entriesOffset |
int | _entryStride |
EqualityComparer< K > | _equalityComparer |
int | _keyOffset |
IElementReaderWriter< K > | _keyReaderWriter |
int | _nxtOffset |
int | _valOffset |
IElementReaderWriter< V > | _valReaderWriter |
Fusion type for networking Dictionaries. Maximum capacity is fixed, and is set with the CapacityAttribute.
Typical Usage: [Networked, Capacity(10)]
NetworkDictionary<int, float> syncedDict => default;
Usage for modifying data: var dict = syncedDict; dict.Add(5, 123); dict[5] = 456; dict.Remove(5);
K | Key can be a primitive, or an INetworkStruct. |
V | Value can be a primitive, or an INetworkStruct. |
NetworkDictionary | ( | int * | data, |
int | capacity, | ||
IElementReaderWriter< K > | keyReaderWriter, | ||
IElementReaderWriter< V > | valReaderWriter | ||
) |
Initializes a new instance of the NetworkDictionary struct with the specified data, capacity, and reader/writers.
data | The pointer to the data of the dictionary. |
capacity | The capacity of the dictionary. |
keyReaderWriter | The reader/writer for the keys of the dictionary. |
valReaderWriter | The reader/writer for the values of the dictionary. |
void INetworkDictionary. Add | ( | object | item | ) |
Adds an item to the networked dictionary.
item | The item to add to the dictionary. |
Implements INetworkDictionary.
bool ContainsValue | ( | V | value, |
IEqualityComparer< V > | equalityComparer = null |
||
) |
Returns true if the Dictionary contains an entry value which compares as equal to given value.
value | The value to compare against. |
equalityComparer | Specify custom IEqualityComparer to be used for compare. |
|
static |
Converts the current NetworkDictionary to a read-only version.
value | The NetworkDictionary to convert. |
bool Remove | ( | K | key | ) |
Remove entry from Dictionary.
key | The key to remove. |
bool Remove | ( | K | key, |
out V | value | ||
) |
Removes entry from Dictionary. If successful (key existed), returns true and the value of removed item.
key | The key to remove. |
value | Returns value of removed item. Returns default value if key did not exist. |
NetworkDictionaryReadOnly< K, V > ToReadOnly | ( | ) |
Converts the current NetworkDictionary to a read-only version.
bool TryGet | ( | K | key, |
out V | value | ||
) |
Attempts to get the value for a given key. If found, returns true.
key | The key to remove. |
value | Returns value of removed item. Returns default value if key did not exist. |