reckfellENGINE

Reckfell.Collections.Dictionary

An engine Variant dictionary for C#: keys, count and copying.

On this page
class Reckfell.Collections.DictionaryReckfellSharp

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
# Dictionary
C#
public Dictionary();

Returns the same dictionary as from. If you need a copy of the dictionary, use Reckfell.Collections.Dictionary.Duplicate.

Properties5

CountProperty
# Count
C#
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
# IsReadOnly
C#
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
# Item
C#
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
# Keys
C#
public System.Collections.Generic.ICollection<Variant> Keys { get; }

Returns the list of keys in the dictionary.

ValuesProperty
# Values
C#
public System.Collections.Generic.ICollection<Variant> Values { get; }

Returns the list of values in this dictionary.

Methods13

Addvoid
# Add
C#
public void Add(Variant key, Variant value);

Adds an value value at key key to this Reckfell.Collections.Dictionary.

Parameters
NameTypeDefault
keyVariant—
valueVariant—
key

The key at which to add the value.

value

The value to add.

Clearvoid
# Clear
C#
public void Clear();

Clears the dictionary, removing all entries from it.

ContainsKeybool
# ContainsKey
C#
public bool ContainsKey(Variant key);

Checks if this Reckfell.Collections.Dictionary contains the given key.

Parameters
NameTypeDefault
keyVariant—
key

The key to look for.

Returns bool

Whether or not this dictionary contains the given key.

Dispose2 overloads
# Dispose · 1/2
C#
public void Dispose();

Disposes of this Reckfell.Collections.Dictionary.

# Dispose · 2/2
C#
public void Dispose(bool disposing);
Parameters
NameTypeDefault
disposingbool—
DuplicateReckfell.Collections.Dictionary
# Duplicate
C#
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.

Parameters
NameTypeDefault
deepboolfalse
deep

If true, performs a deep copy.

Returns Reckfell.Collections.Dictionary

A new Reckfell Dictionary.

GetEnumeratorSystem.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<Variant, Variant>>
# GetEnumerator
C#
public System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<Variant, Variant>> GetEnumerator();

Gets an enumerator for this Reckfell.Collections.Dictionary.

Returns System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<Variant, Variant>>

An enumerator.

MakeReadOnlyvoid
# MakeReadOnly
C#
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
# Merge
C#
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.

C#
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.

Parameters
NameTypeDefault
dictionaryReckfell.Collections.Dictionary—
overwriteboolfalse
dictionary

Dictionary to copy entries from.

overwrite

If duplicate keys should be copied over as well.

RecursiveEqualbool
# RecursiveEqual
C#
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.

Parameters
NameTypeDefault
otherReckfell.Collections.Dictionary—
other

The other dictionary to compare against.

Returns bool

true if the dictionaries contain the same keys and values, false otherwise.

Removebool
# Remove
C#
public bool Remove(Variant key);

Removes an element from this Reckfell.Collections.Dictionary by key.

Parameters
NameTypeDefault
keyVariant—
key

The key of the element to remove.

Returns bool
ToStringstring
# ToString
C#
public override string ToString();

Converts this Reckfell.Collections.Dictionary to a string.

Returns string

A string representation of this dictionary.

TryGetValuebool
# TryGetValue
C#
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.

Parameters
NameTypeDefault
keyVariant—
valueVariant—
key

Key to look up using Dictionary key-comparison rules.

value

On success the key value, including Nil; when absent a default Variant. A container inside the value can remain shared.

Returns bool

True when the key exists, regardless of its value tag.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.