public virtual void AddIndependendVariableValues <T>(IVariable variable, IEnumerable <T> values) { if (!Functions.Contains(variable)) { throw new ArgumentOutOfRangeException("variable", "Function is not a part of the store, add it to the Functions first."); } IMultiDimensionalArray variableValuesArray = FunctionValues[Functions.IndexOf(variable)]; bool addingNewValues = variableValuesArray.Count == 0; foreach (T o in values) { if (addingNewValues) { variableValuesArray.Add(o); } else { if (!variableValuesArray.Contains(o)) // TODO: slow, optimize it somehow { variableValuesArray.Add(o); } } } }
private IMultiDimensionalArray GetValues(IVariable variable) { if (variable.CachedValues == null) { variable.CachedValues = FunctionValues[functions.IndexOf(variable)]; } return(variable.CachedValues); }
private void SetIndependendFunctionValues(IVariable variable, IVariableFilter[] filters, IEnumerable values) { IMultiDimensionalArray array = FunctionValues[functions.IndexOf(variable)]; if (filters.Length != 0) { throw new ArgumentException("don't use filters to set independend variables. the only exception is an index filter with index equal to count"); } array.AddRange(values); }
public virtual object Clone() { var clonedNetwork = (Network)Activator.CreateInstance(GetType()); clonedNetwork.Name = Name; clonedNetwork.Geometry = Geometry == null ? null : ((IGeometry)Geometry.Clone()); foreach (var node in Nodes) { INode clonedNode = (INode)node.Clone(); clonedNetwork.Nodes.Add(clonedNode); } foreach (IBranch branch in Branches) { IBranch clonedBranch = (IBranch)branch.Clone(); clonedBranch.Source = clonedNetwork.Nodes[Nodes.IndexOf(branch.Source)]; clonedBranch.Target = clonedNetwork.Nodes[nodes.IndexOf(branch.Target)]; clonedNetwork.Branches.Add(clonedBranch); } return(clonedNetwork); }
public virtual void AddIndependendVariableValues <T>(IVariable variable, IEnumerable <T> values) { ThrowIfVariableNotPartOfStore(variable); IMultiDimensionalArray variableValuesArray = FunctionValues[Functions.IndexOf(variable)]; bool addingNewValues = variableValuesArray.Count == 0; foreach (T o in values) { if (addingNewValues || variable.SkipUniqueValuesCheck) { variableValuesArray.Add(o); } else { if (!variableValuesArray.Contains(o)) // TODO: slow, optimize it somehow { variableValuesArray.Add(o); } } } }