Class VariableDictionary<V>
An implementation of the IVariableDictionary<V>.
Implements
Inherited Members
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 |
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 |
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 |
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 |
|
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
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 |
Returns
Type | Description |
---|---|
bool |
|
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |