Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/StatelessExpression.cs

Last change on this file was 15344, checked in by pkimmesw, 7 years ago

#2665 Fixed Integer Overflow Exceptions, Adjusted Offspring Selection Experiments

File size: 1.0 KB
Line 
1namespace HeuristicLab.Problems.ProgramSynthesis.Push.Expressions {
2  using System;
3
4  using HeuristicLab.Common;
5  using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
6
7  [StorableClass]
8  [Serializable]
9  public abstract class StatelessExpression : Expression {
10    [NonSerialized]
11    private readonly int hashCode;
12
13    protected StatelessExpression() {
14      hashCode = GetType().FullName.GetHashCode();
15    }
16
17    [StorableConstructor]
18    protected StatelessExpression(bool deserializing) : base(deserializing) { }
19
20    protected StatelessExpression(StatelessExpression origin, Cloner cloner) : base(origin, cloner) { }
21
22    public override int GetHashCode() {
23      return hashCode;
24    }
25
26    public override string StringRepresentation
27    {
28      get
29      {
30        return ExpressionTable.TypeToAttributeTable[GetType()].Name;
31      }
32    }
33
34    public override bool Equals(object obj) {
35      return ReferenceEquals(this, obj) ||
36             hashCode == obj.GetHashCode();
37    }
38  }
39}
Note: See TracBrowser for help on using the repository browser.