Reckfell.Collections.Dictionary
An engine Variant dictionary for C#: keys, count and copying.
A C# class in Reckfell.Collections wrapping an engine dictionary of Variant keys and Variant values. It is not System.Collections.Generic.Dictionary<TKey, TValue>; the typed engine wrapper is Reckfell.Collections.Dictionary<TKey, TValue>.
Assignment copies a reference. Duplicate() creates a separate top-level dictionary; deep controls nested array/dictionary copying and does not automatically clone every engine object.
The dictionary has no C# truth value. Test Count == 0 or Count > 0, and use is null for a missing reference. A nonempty dictionary does not prove a particular key is present; test the key separately.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
DictionaryConstructor
public Dictionary();Returns the same dictionary as from. If you need a copy of the dictionary, use Reckfell.Collections.Dictionary.Duplicate.
Properties5
CountProperty
public int Count { get; }Returns the number of elements in this Reckfell.Collections.Dictionary.
This is also known as the size or length of the dictionary.
IsReadOnlyProperty
public bool IsReadOnly { get; }Returns true if the dictionary is read-only. See Reckfell.Collections.Dictionary.MakeReadOnly. Dictionaries are automatically read-only if declared with const keyword.
ItemProperty
public Variant this[Variant key] { get; set; }Reads an existing key value or sets a key value. Reading a missing key throws KeyNotFoundException; use TryGetValue to test presence. A present Nil value differs from absence.
KeysProperty
public System.Collections.Generic.ICollection<Variant> Keys { get; }Returns the list of keys in the dictionary.
ValuesProperty
public System.Collections.Generic.ICollection<Variant> Values { get; }Returns the list of values in this dictionary.
Methods13
Addvoid
public void Add(Variant key, Variant value);Adds an value value at key key
to this Reckfell.Collections.Dictionary.
| Name | Type | Default |
|---|---|---|
key | Variant | — |
value | Variant | — |
keyThe key at which to add the value.
valueThe value to add.
Clearvoid
public void Clear();Clears the dictionary, removing all entries from it.
ContainsKeybool
public bool ContainsKey(Variant key);Checks if this Reckfell.Collections.Dictionary contains the given key.
| Name | Type | Default |
|---|---|---|
key | Variant | — |
keyThe key to look for.
boolWhether or not this dictionary contains the given key.
Dispose2 overloads
public void Dispose();Disposes of this Reckfell.Collections.Dictionary.
public void Dispose(bool disposing);| Name | Type | Default |
|---|---|---|
disposing | bool | — |
DuplicateReckfell.Collections.Dictionary
public Reckfell.Collections.Dictionary Duplicate(bool deep = false);Returns a new copy of the dictionary.
By default, a shallow copy is returned: all nested Reckfell.Collections.Array, Reckfell.Collections.Dictionary, and Resource keys and values are shared with the original dictionary. Modifying any of those in one dictionary will also affect them in the other.
If deep is true, a deep copy is returned: all nested arrays and dictionaries are also duplicated (recursively). Any Resource is still shared with the original dictionary, though.
| Name | Type | Default |
|---|---|---|
deep | bool | false |
deepIf true, performs a deep copy.
Reckfell.Collections.DictionaryA new Reckfell Dictionary.
GetEnumeratorSystem.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<Variant, Variant>>
public System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<Variant, Variant>> GetEnumerator();Gets an enumerator for this Reckfell.Collections.Dictionary.
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<Variant, Variant>>An enumerator.
MakeReadOnlyvoid
public void MakeReadOnly();Makes the dictionary read-only, i.e. disables modification of the dictionary's contents. Does not apply to nested content, e.g. content of nested dictionaries.
Mergevoid
public void Merge(Reckfell.Collections.Dictionary dictionary, bool overwrite = false);Adds entries from dictionary to this dictionary. By default, duplicate keys are not copied over, unless overwrite is true.
var dict = new Reckfell.Collections.Dictionary
{
["item"] = "sword",
["quantity"] = 2,
};
var otherDict = new Reckfell.Collections.Dictionary
{
["quantity"] = 15,
["color"] = "silver",
};
// Overwriting of existing keys is disabled by default.
dict.Merge(otherDict);
ReckfellApi.Print(dict); // { "item": "sword", "quantity": 2, "color": "silver" }
// With overwriting of existing keys enabled.
dict.Merge(otherDict, true);
ReckfellApi.Print(dict); // { "item": "sword", "quantity": 15, "color": "silver" }Note: Reckfell.Collections.Dictionary.Merge is not recursive. Nested dictionaries are considered as keys that can be overwritten or not depending on the value of overwrite, but they will never be merged together.
| Name | Type | Default |
|---|---|---|
dictionary | Reckfell.Collections.Dictionary | — |
overwrite | bool | false |
dictionaryDictionary to copy entries from.
overwriteIf duplicate keys should be copied over as well.
RecursiveEqualbool
public bool RecursiveEqual(Reckfell.Collections.Dictionary other);Returns true if the two dictionaries contain the same keys and values, inner Reckfell.Collections.Dictionary and Reckfell.Collections.Array keys and values are compared recursively.
| Name | Type | Default |
|---|---|---|
other | Reckfell.Collections.Dictionary | — |
otherThe other dictionary to compare against.
booltrue if the dictionaries contain the same keys and values,
false otherwise.
Removebool
public bool Remove(Variant key);Removes an element from this Reckfell.Collections.Dictionary by key.
| Name | Type | Default |
|---|---|---|
key | Variant | — |
keyThe key of the element to remove.
boolToStringstring
public override string ToString();Converts this Reckfell.Collections.Dictionary to a string.
stringA string representation of this dictionary.
TryGetValuebool
public bool TryGetValue(Variant key, out Variant value);Tests key presence and retrieves its value without a missing-key exception. True with Nil means a present key; false means an absent key and a default output Variant.
| Name | Type | Default |
|---|---|---|
key | Variant | — |
value | Variant | — |
keyKey to look up using Dictionary key-comparison rules.
valueOn success the key value, including Nil; when absent a default Variant. A container inside the value can remain shared.
boolTrue when the key exists, regardless of its value tag.