Changeset 15189 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/PushProgram.cs
- Timestamp:
- 07/10/17 21:36:03 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/PushProgram.cs
r15017 r15189 8 8 using Data.Pool; 9 9 using Extensions; 10 11 using HeuristicLab.Common; 12 10 13 using Interpreter; 11 14 using Persistence.Default.CompositeSerializers.Storable; … … 41 44 } 42 45 46 public PushProgram(PushProgram origin, Cloner cloner) { 47 stringRepresentation = origin.stringRepresentation; 48 hashCode = origin.hashCode; 49 depth = origin.depth; 50 treeIndex = origin.treeIndex; 51 expressions = new List<Expression>(origin.expressions); 52 } 53 54 public override IDeepCloneable Clone(Cloner cloner) { 55 return new PushProgram(this, cloner); 56 } 57 43 58 public bool IsEmpty { get { return Count == 0; } } 44 59 public int Count { get { return expressions.Count; } } … … 51 66 return program; 52 67 } 68 69 void IPooledObject.Init() { } 53 70 54 71 void IPooledObject.Reset() { … … 263 280 yield return sub; 264 281 else yield return expr; 282 } 283 } 284 285 public IReadOnlyList<Expression> Flatten() { 286 var result = new List<Expression>(); 287 Flatten(result); 288 return result; 289 } 290 291 private void Flatten(List<Expression> result) { 292 result.AddRange(expressions); 293 294 for (var i = 0; i < expressions.Count; i++) { 295 var expr = expressions[i]; 296 if (expr.IsProgram) { 297 ((PushProgram)expr).Flatten(result); 298 } 265 299 } 266 300 }
Note: See TracChangeset
for help on using the changeset viewer.