Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/22/18 21:57:59 (6 years ago)
Author:
bburlacu
Message:

#2886: Fix hashing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/Symbol.cs

    r16053 r16176  
    2626namespace HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration {
    2727  [StorableClass]
    28   public abstract class Symbol : DeepCloneable, IEquatable<Symbol> {
     28  public abstract class Symbol : DeepCloneable, IEquatable<Symbol>, IComparable<Symbol> {
    2929    [Storable]
    3030    private readonly int stringRepresentationHash;
     
    7878      return stringRepresentationHash;
    7979    }
     80
     81    public int CompareTo(Symbol other) {
     82      var v1 = this as VariableTerminalSymbol;
     83      var v2 = other as VariableTerminalSymbol;
     84
     85      if ((v1 == null && v2 == null) || (v1 != null && v2 != null))
     86        return this.StringRepresentation.CompareTo(other.StringRepresentation);
     87      return v1 == null ? 1 : -1;
     88    }
    8089    #endregion
    8190  }
     
    119128    protected NonterminalSymbol(bool deserializing) : base(deserializing) { }
    120129  }
    121 
    122 
    123130}
Note: See TracChangeset for help on using the changeset viewer.