Show / Hide Table of Contents

Class VariableDictionary<V>

An implementation of the IVariableDictionary<V>.

Inheritance
object
VariableDictionary<V>
FrequencySimulation.ComplexSimulationState
VariableFactory
Implements
IVariableDictionary<V>
IReadOnlyDictionary<string, V>
IReadOnlyCollection<KeyValuePair<string, V>>
IEnumerable<KeyValuePair<string, V>>
IEnumerable
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: SpiceSharp.Simulations
Assembly: SpiceSharp.dll
Syntax
public class VariableDictionary<V> : IVariableDictionary<V>, IReadOnlyDictionary<string, V>, IReadOnlyCollection<KeyValuePair<string, V>>, IEnumerable<KeyValuePair<string, V>>, IEnumerable where V : IVariable
Type Parameters
Name Description
V

The variable type.

Constructors

VariableDictionary()

Initializes a new instance of the VariableDictionary<V> class.

Declaration
public VariableDictionary()

VariableDictionary(IEqualityComparer<string>)

Initializes a new instance of the VariableDictionary<V> class.

Declaration
public VariableDictionary(IEqualityComparer<string> comparer)
Parameters
Type Name Description
IEqualityComparer<string> comparer

The IEqualityComparer<T> implementation to use when comparing variable names, or null to use the default EqualityComparer<T>.

Properties

Comparer

Gets the comparer used for comparing variable names.

Declaration
public IEqualityComparer<string> Comparer { get; }
Property Value
Type Description
IEqualityComparer<string>

The comparer.

Count

Gets the number of variables in the dictionary.

Declaration
public int Count { get; }
Property Value
Type Description
int

The number of variables in the dictionary.

this[string]

Gets the IVariable with the specified identifier.

Declaration
public V this[string name] { get; }
Parameters
Type Name Description
string name

The name.

Property Value
Type Description
V

The IVariable.

Exceptions
Type Condition
ArgumentNullException

Thrown if name is null.

KeyNotFoundException

Thrown if the variable couldn't be found.

Keys

Gets an enumerable collection that contains the identifiers of all variables in the set.

Declaration
public IEnumerable<string> Keys { get; }
Property Value
Type Description
IEnumerable<string>

An enumerable of all the identifiers in the dictionary.

Values

Gets an enumerable collection that contains the variables in the set.

Declaration
public IEnumerable<V> Values { get; }
Property Value
Type Description
IEnumerable<V>

An enumerable of all the variables in the dictionary.

Methods

Add(string, V)

Adds a variable to the dictionary.

Declaration
public void Add(string id, V variable)
Parameters
Type Name Description
string id

The identifier.

V variable

The variable.

Exceptions
Type Condition
ArgumentNullException

Thrown if id or variable is null.

ArgumentException

Thrown if a variable with the same identifier already exists.

ContainsKey(string)

Determines whether the dictionary contains an element that has the specified key.

Declaration
public bool ContainsKey(string key)
Parameters
Type Name Description
string key

The key to locate.

Returns
Type Description
bool

true if the read-only dictionary contains an element that has the specified key; otherwise, false.

Exceptions
Type Condition
ArgumentNullException

Thrown if key is null.

GetEnumerator()

Returns an enumerator that iterates through the collection.

Declaration
public IEnumerator<KeyValuePair<string, V>> GetEnumerator()
Returns
Type Description
IEnumerator<KeyValuePair<string, V>>

An enumerator that can be used to iterate through the collection.

TryGetValue(string, out V)

Gets the value that is associated with the specified key.

Declaration
public bool TryGetValue(string key, out V value)
Parameters
Type Name Description
string key

The key to locate.

V value

When this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.

Returns
Type Description
bool

true if the dictionary contains an element that has the specified key; otherwise, false.

Exceptions
Type Condition
ArgumentNullException

Thrown if key is null.

Implements

IVariableDictionary<V>
IReadOnlyDictionary<TKey, TValue>
IReadOnlyCollection<T>
IEnumerable<T>
IEnumerable

Extension Methods

Utility.ThrowIfNull<T>(T, string)
Utility.ThrowIfEmpty<T>(IEnumerable<T>, string)

See Also

IVariableDictionary<V>
IVariable
In this article
Back to top Generated by DocFX