Changeset 14730 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/StatefullExpression.cs
- Timestamp:
- 03/08/17 10:23:51 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/StatefullExpression.cs
r14727 r14730 1 1 namespace HeuristicLab.Problems.ProgramSynthesis.Push.Expressions { 2 using System;3 2 4 3 public abstract class StatefullExpression<T> : Expression { 5 4 6 5 public readonly T State; 7 private readonly Lazy<int> hashCode; 6 7 private int hashCode; 8 private int HashCode { 9 get { 10 if (hashCode == default(int)) hashCode = CalcHashCode(); 11 return hashCode; 12 } 13 } 8 14 9 15 protected StatefullExpression(T state) { 10 16 this.State = state; 11 this.hashCode = new Lazy<int>(this.CalcHashCode, true);12 17 } 13 18 … … 30 35 31 36 public override int GetHashCode() { 32 return this.hashCode.Value;37 return HashCode; 33 38 } 34 39 }
Note: See TracChangeset
for help on using the changeset viewer.