Changeset 14777 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/StatefulExpression.cs
- Timestamp:
- 03/23/17 01:11:18 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/StatefulExpression.cs
r14746 r14777 1 1 namespace HeuristicLab.Problems.ProgramSynthesis.Push.Expressions { 2 public abstract class StatefulExpression<T> : Expression { 3 public readonly T State; 2 using System; 3 4 using HeuristicLab.Problems.ProgramSynthesis.Push.Data.Pool; 5 6 [Serializable] 7 public abstract class StatefulExpression<T> : Expression, IPooledObject { 8 public T State { get; protected set; } 4 9 private int? hashCode; 10 private string stringRepresentation; 5 11 6 12 protected StatefulExpression(T state) { … … 10 16 protected virtual int CalcHashCode() { 11 17 return this.State.GetHashCode(); 18 } 19 20 public override string StringRepresentation 21 { 22 get 23 { 24 if (stringRepresentation == null) stringRepresentation = this.State.ToString(); 25 return stringRepresentation; 26 } 12 27 } 13 28 … … 40 55 return hashCode.Value; 41 56 } 57 58 public void Reset() { 59 State = default(T); 60 } 42 61 } 43 62 }
Note: See TracChangeset
for help on using the changeset viewer.