Changeset 6284 for branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs
- Timestamp:
- 05/25/11 10:50:21 (14 years ago)
- Location:
- branches/GP.Grammar.Editor
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/SymbolicExpressionGrammarBase.cs
r6233 r6284 93 93 cachedMinExpressionDepth = new Dictionary<string, int>(); 94 94 95 96 95 symbols = original.symbols.ToDictionary(x => x.Key, y => (ISymbol)cloner.Clone(y.Value)); 97 96 symbolSubtreeCount = new Dictionary<string, Tuple<int, int>>(original.symbolSubtreeCount); … … 128 127 symbolSubtreeCount.Add(symbol.Name, Tuple.Create(0, 0)); 129 128 ClearCaches(); 129 OnChanged(); 130 130 } 131 131 … … 133 133 symbol.NameChanging += new EventHandler<CancelEventArgs<string>>(Symbol_NameChanging); 134 134 symbol.NameChanged += new EventHandler(Symbol_NameChanged); 135 symbol.Changed += new EventHandler(Symbol_Changed); 135 136 } 136 137 private void DeregisterSymbolEvents(ISymbol symbol) { 137 138 symbol.NameChanging -= new EventHandler<CancelEventArgs<string>>(Symbol_NameChanging); 138 139 symbol.NameChanged -= new EventHandler(Symbol_NameChanged); 140 symbol.Changed -= new EventHandler(Symbol_Changed); 139 141 } 140 142 … … 179 181 180 182 ClearCaches(); 183 OnChanged(); 184 } 185 186 private void Symbol_Changed(object sende, EventArgs e) { 187 ClearCaches(); 188 OnChanged(); 181 189 } 182 190 … … 200 208 DeregisterSymbolEvents(symbol); 201 209 ClearCaches(); 210 OnChanged(); 202 211 } 203 212 … … 217 226 childSymbols.Add(child.Name); 218 227 ClearCaches(); 228 OnChanged(); 219 229 } 220 230 … … 231 241 childSymbols.Add(child.Name); 232 242 ClearCaches(); 243 OnChanged(); 233 244 } 234 245 … … 236 247 List<string> childSymbols; 237 248 if (allowedChildSymbols.TryGetValue(child.Name, out childSymbols)) { 238 if (allowedChildSymbols[parent.Name].Remove(child.Name)) 249 if (allowedChildSymbols[parent.Name].Remove(child.Name)) { 239 250 ClearCaches(); 251 OnChanged(); 252 } 240 253 } 241 254 } … … 245 258 List<string> childSymbols; 246 259 if (allowedChildSymbolsPerIndex.TryGetValue(key, out childSymbols)) { 247 if (allowedChildSymbolsPerIndex[key].Remove(child.Name)) 260 if (allowedChildSymbolsPerIndex[key].Remove(child.Name)) { 248 261 ClearCaches(); 262 OnChanged(); 263 } 249 264 } 250 265 } … … 258 273 symbolSubtreeCount[symbol.Name] = Tuple.Create(minimumSubtreeCount, maximumSubtreeCount); 259 274 ClearCaches(); 275 OnChanged(); 260 276 } 261 277 #endregion … … 304 320 result = result.Union(temp); 305 321 306 return result.Select(x => GetSymbol(x)) ;322 return result.Select(x => GetSymbol(x)).Where(s => !s.InitialFrequency.IsAlmost(0.0)); 307 323 } 308 324 … … 313 329 return symbolSubtreeCount[symbol.Name].Item2; 314 330 } 315 316 331 317 332 private void ClearCaches() { … … 369 384 return temp; 370 385 } 386 387 public event EventHandler Changed; 388 protected virtual void OnChanged() { 389 var handler = Changed; 390 if (handler != null) Changed(this, EventArgs.Empty); 391 } 371 392 #endregion 372 393 }
Note: See TracChangeset
for help on using the changeset viewer.