Changeset 14746 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/StatefulExpression.cs
- Timestamp:
- 03/11/17 20:07:13 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/StatefulExpression.cs
r14745 r14746 2 2 public abstract class StatefulExpression<T> : Expression { 3 3 public readonly T State; 4 5 private int hashCode; 6 private int HashCode 7 { 8 get 9 { 10 if (hashCode == default(int)) hashCode = CalcHashCode(); 11 return hashCode; 12 } 13 } 4 private int? hashCode; 14 5 15 6 protected StatefulExpression(T state) { … … 34 25 } 35 26 27 public bool Equals(StatefulExpression<T> obj) { 28 if (ReferenceEquals(this, obj)) 29 return true; 30 31 if (GetType() != obj.GetType()) 32 return false; 33 34 return ReferenceEquals(State, obj.State) || 35 GetHashCode() == obj.GetHashCode(); 36 } 37 36 38 public override int GetHashCode() { 37 return HashCode; 39 if (hashCode == null) hashCode = CalcHashCode(); 40 return hashCode.Value; 38 41 } 39 42 }
Note: See TracChangeset
for help on using the changeset viewer.