Skip to content

Collections Dictionary

Eduard Gushchin edited this page Jun 21, 2026 · 5 revisions

Home | API by Category | Complete API Index | API Compatibility

Field Value
Full name Electron2D.Collections.Dictionary
Namespace Electron2D.Collections
Kind class
Category Math and Data

Overview

Stores mutable key/value pairs where both keys and values are Electron2D.Variant.

Syntax

public sealed class Electron2D.Collections.Dictionary : System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<Electron2D.Variant, Electron2D.Variant>>, System.Collections.IEnumerable

Remarks

This type is intentionally limited to Electron2D.Variant keys and Electron2D.Variant values so the supported value set stays closed.

The container itself is reference-like: assigning the same instance to multiple variants stores the same mutable dictionary object.

Thread Safety

This type is not synchronized. External synchronization is required when the same instance is mutated from multiple threads.

Since

This type is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Collections.Array
  • Electron2D.Variant

Members

Member Kind Summary
Count Property Gets the number of key/value pairs stored in the dictionary.
Item Property Gets or sets the value stored for a key.
Electron2D.Collections.Dictionary() Constructor Initializes a new instance of the Dictionary type.
Add(Electron2D.Variant, Electron2D.Variant) Method Adds a key/value pair to the dictionary.
Clear() Method Removes all key/value pairs from the dictionary.
ContainsKey(Electron2D.Variant) Method Checks whether the dictionary contains a key.
GetEnumerator() Method Returns an enumerator over the current key/value pairs.
Remove(Electron2D.Variant) Method Removes a key and its value.
ToString() Method Returns a diagnostic string representation of this dictionary.
TryGetValue(Electron2D.Variant, Electron2D.Variant&) Method Attempts to read a value without throwing when the key is missing.

Member Details

Count

Kind: Property

public System.Int32 Count { get; }

Summary

Gets the number of key/value pairs stored in the dictionary.

Remarks

This value changes when Electron2D.Collections.Dictionary.Add(Electron2D.Variant,Electron2D.Variant), Electron2D.Collections.Dictionary.Remove(Electron2D.Variant) or Electron2D.Collections.Dictionary.Clear mutates the container.

Value

The current number of stored key/value pairs.

Thread Safety

This property is not synchronized. External synchronization is required when the same instance is accessed from multiple threads.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Collections.Dictionary

Item

Kind: Property

public Electron2D.Variant this[Electron2D.Variant key] { get; set; }

Summary

Gets or sets the value stored for a key.

Remarks

The getter reads the live mutable container. The setter adds or replaces the value associated with key.

Parameters

  • key: The key to read or write.

Returns

The value stored for key.

Value

The value at the specified index.

Exceptions

  • System.Collections.Generic.KeyNotFoundException: Thrown when the getter is used and key is not present.

Thread Safety

This indexer is not synchronized. External synchronization is required when the same instance is accessed from multiple threads.

Since

This indexer is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Collections.Dictionary.Add(Electron2D.Variant,Electron2D.Variant)
  • Electron2D.Collections.Dictionary.ContainsKey(Electron2D.Variant)

Electron2D.Collections.Dictionary()

Kind: Constructor

public Electron2D.Collections.Dictionary()

Summary

Initializes a new instance of the Dictionary type.

Remarks

The new instance follows the lifetime and validation rules of its declaring type.

Thread Safety

This member is not synchronized. Call it from the thread that owns the related object unless the declaring type states otherwise.

Since

This API is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Collections.Dictionary

Add(Electron2D.Variant, Electron2D.Variant)

Kind: Method

public System.Void Add(Electron2D.Variant, Electron2D.Variant)(Electron2D.Variant key, Electron2D.Variant value)

Summary

Adds a key/value pair to the dictionary.

Remarks

Use the indexer to replace an existing value. This method is strict and rejects duplicate keys.

Parameters

  • key: The key to add.
  • value: The value to store for key.

Exceptions

  • System.ArgumentException: Thrown when key already exists.

Thread Safety

This method is not synchronized. External synchronization is required when the same instance is mutated from multiple threads.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Collections.Dictionary.ContainsKey(Electron2D.Variant)
  • Electron2D.Collections.Dictionary.Remove(Electron2D.Variant)

Clear()

Kind: Method

public System.Void Clear()()

Summary

Removes all key/value pairs from the dictionary.

Remarks

Existing references to this Electron2D.Collections.Dictionary observe the same mutable instance after it has been cleared.

Thread Safety

This method is not synchronized. External synchronization is required when the same instance is mutated from multiple threads.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Collections.Dictionary.Count

ContainsKey(Electron2D.Variant)

Kind: Method

public System.Boolean ContainsKey(Electron2D.Variant)(Electron2D.Variant key)

Summary

Checks whether the dictionary contains a key.

Remarks

This method does not throw when key is missing.

Parameters

  • key: The key to search for.

Returns

true if the key is present; otherwise, false.

Thread Safety

This method is not synchronized. External synchronization is required when the same instance is accessed from multiple threads.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Collections.Dictionary.TryGetValue(Electron2D.Variant,Electron2D.Variant@)

GetEnumerator()

Kind: Method

public System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<Electron2D.Variant, Electron2D.Variant>> GetEnumerator()()

Summary

Returns an enumerator over the current key/value pairs.

Remarks

The enumerator follows the behavior of the underlying CLR dictionary. Mutating this container while enumerating it invalidates the enumerator.

Returns

An enumerator over key/value pairs.

Thread Safety

This method is not synchronized. External synchronization is required when the same instance may be mutated while it is being enumerated.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Collections.Dictionary.TryGetValue(Electron2D.Variant,Electron2D.Variant@)

Remove(Electron2D.Variant)

Kind: Method

public System.Boolean Remove(Electron2D.Variant)(Electron2D.Variant key)

Summary

Removes a key and its value.

Remarks

Removing a missing key is a no-op and returns false.

Parameters

  • key: The key to remove.

Returns

true if the key was found and removed; otherwise, false.

Thread Safety

This method is not synchronized. External synchronization is required when the same instance is mutated from multiple threads.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Collections.Dictionary.Add(Electron2D.Variant,Electron2D.Variant)
  • Electron2D.Collections.Dictionary.Clear

ToString()

Kind: Method

public System.String ToString()()

Summary

Returns a diagnostic string representation of this dictionary.

Remarks

The result is intended for diagnostics and logs. It is not a stable serialization format.

Returns

A comma-separated list of key/value pairs wrapped in braces.

Thread Safety

This method is not synchronized. External synchronization is required when the same instance may be mutated while the string is being built.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Collections.Dictionary

TryGetValue(Electron2D.Variant, Electron2D.Variant&)

Kind: Method

public System.Boolean TryGetValue(Electron2D.Variant, Electron2D.Variant&)(Electron2D.Variant key, Electron2D.Variant& value)

Summary

Attempts to read a value without throwing when the key is missing.

Remarks

This method is the non-throwing read path for optional dictionary keys.

Parameters

  • key: The key to search for.
  • value: Receives the stored value when the key is present; otherwise receives default(Variant).

Returns

true if the key is present; otherwise, false.

Thread Safety

This method is not synchronized. External synchronization is required when the same instance is accessed from multiple threads.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.Collections.Dictionary.ContainsKey(Electron2D.Variant)

Clone this wiki locally