Changeset 15960 for branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/Hashing
- Timestamp:
- 06/15/18 14:53:46 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/Hashing/Hasher.cs
r15851 r15960 3 3 using System.Diagnostics; 4 4 using System.Linq; 5 using HeuristicLab.Common; 6 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 5 7 6 8 namespace HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration.GrammarEnumeration { 7 public abstract class Hasher<THashType> { 9 [StorableClass] 10 public abstract class Hasher<THashType> : DeepCloneable { 8 11 protected Hasher(Grammar grammar) { 9 12 Grammar = grammar; 13 } 14 15 protected Hasher(Hasher<THashType> original, Cloner cloner) : base(original, cloner) { 16 Grammar = cloner.Clone(original.Grammar); 10 17 } 11 18 … … 22 29 return AggregateHashes(peek, GetSubtreeHashes(parseStack)).GetHashCode(); 23 30 } 31 32 [StorableConstructor] 33 protected Hasher(bool deserializing) { } 24 34 25 35 private THashType[] GetSubtreeHashes(Stack<Symbol> parseStack) { … … 109 119 .ToArray(); 110 120 } 111 112 113 121 } 114 122 123 [StorableClass] 115 124 public class IntHasher : Hasher<int> { 116 125 public IntHasher(Grammar grammar) : base(grammar) { } 126 127 public IntHasher(IntHasher original, Cloner cloner) : base(original, cloner) { } 128 129 public override IDeepCloneable Clone(Cloner cloner) { 130 return new IntHasher(this, cloner); 131 } 132 133 [StorableConstructor] 134 protected IntHasher(bool deserializing) : base(deserializing) { } 117 135 118 136 protected override int AggregateHashes(Symbol operatorSym, int[] hashes) { … … 135 153 } 136 154 155 [StorableClass] 137 156 public class StringHasher : Hasher<string> { 138 157 public StringHasher(Grammar grammar) : base(grammar) { } 158 159 public StringHasher(StringHasher original, Cloner cloner) : base(original, cloner) { } 160 161 public override IDeepCloneable Clone(Cloner cloner) { 162 return new StringHasher(this, cloner); 163 } 164 165 [StorableConstructor] 166 protected StringHasher(bool deserializing) : base(deserializing) { } 139 167 140 168 protected override string AggregateHashes(Symbol operatorSym, string[] hashes) {
Note: See TracChangeset
for help on using the changeset viewer.