Class VariableMap
A default implementation for a variable map.
Inherited Members
Namespace: SpiceSharp.Simulations
Assembly: SpiceSharp.dll
Syntax
public class VariableMap : IVariableMap, IEnumerable<KeyValuePair<IVariable, int>>, IEnumerable
Remarks
Can be used to map to indices for a solver that uses matrix equations.
Constructors
VariableMap(IVariable)
Initializes a new instance of the VariableMap class.
Declaration
public VariableMap(IVariable ground)
Parameters
Type | Name | Description |
---|---|---|
IVariable | ground | The ground variable that receives index 0. |
Properties
Count
Gets the number of mapped variables.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int | The number of mapped variables. |
this[IVariable]
Gets the index associated with the specified variable.
Declaration
public int this[IVariable variable] { get; }
Parameters
Type | Name | Description |
---|---|---|
IVariable | variable | The variable. |
Property Value
Type | Description |
---|---|
int | The index. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
KeyNotFoundException | Thrown if the variable was not found. |
this[int]
Gets the variable associated to the specified index.
Declaration
public IVariable this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
int | index | The index. |
Property Value
Type | Description |
---|---|
IVariable | The variable. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if no variable was found at the specified index. |
Methods
Add(IVariable, int)
Adds the specified variable.
Declaration
public void Add(IVariable variable, int index)
Parameters
Type | Name | Description |
---|---|---|
IVariable | variable | The variable. |
int | index | The index. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown if the index is not strictly positive. |
ArgumentException | Thrown if a variable already exists with the same index. |
Clear()
Clears the map.
Declaration
public void Clear()
Contains(IVariable)
Determines whether a variable is mapped.
Declaration
public bool Contains(IVariable variable)
Parameters
Type | Name | Description |
---|---|---|
IVariable | variable | The variable. |
Returns
Type | Description |
---|---|
bool |
|
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<KeyValuePair<IVariable, int>> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<KeyValuePair<IVariable, int>> | An enumerator that can be used to iterate through the collection. |