Changeset 192 for trunk/sources/HeuristicLab.Functions/FunctionTree.cs
- Timestamp:
- 04/25/08 14:46:58 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Functions/FunctionTree.cs
r189 r192 93 93 } 94 94 95 double[] evaluationResults; 95 96 public virtual double Evaluate(Dataset dataset, int sampleIndex) { 96 double[] evaluationResults = new double[SubTrees.Count]; 97 // lazy creation of evaluationResults to unburden the GC 98 if(evaluationResults == null) { 99 evaluationResults = new double[SubTrees.Count]; 100 } 97 101 for(int i = 0; i < evaluationResults.Length; i++) { 98 102 evaluationResults[i] = SubTrees[i].Evaluate(dataset, sampleIndex); … … 128 132 129 133 public override object Clone(IDictionary<Guid, object> clonedObjects) { 130 FunctionTree clone = (FunctionTree)base.Clone(clonedObjects); 134 FunctionTree clone = new FunctionTree(); 135 clonedObjects.Add(clone.Guid, clone); 136 FillClone(clone, clonedObjects); 137 return clone; 138 } 139 140 public void FillClone(FunctionTree clone, IDictionary<Guid, object> clonedObjects) { 141 clone.function = function; 142 foreach(IVariable variable in localVariables) { 143 clone.AddVariable((IVariable)variable.Clone(clonedObjects)); 144 } 131 145 foreach(IFunctionTree tree in subTrees) { 132 146 clone.AddSubTree((IFunctionTree)tree.Clone(clonedObjects)); 133 147 } 134 foreach(IVariable variable in localVariables) {135 clone.AddVariable((IVariable)variable.Clone(clonedObjects));136 }137 clone.function = function;138 return clone;139 148 } 140 149
Note: See TracChangeset
for help on using the changeset viewer.