当前位置: 首页>>代码示例>>C#>>正文


C# ISymbol.Flatten方法代码示例

本文整理汇总了C#中ISymbol.Flatten方法的典型用法代码示例。如果您正苦于以下问题:C# ISymbol.Flatten方法的具体用法?C# ISymbol.Flatten怎么用?C# ISymbol.Flatten使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISymbol的用法示例。


在下文中一共展示了ISymbol.Flatten方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddAllowedChildSymbol

    public virtual void AddAllowedChildSymbol(ISymbol parent, ISymbol child, int argumentIndex) {
      bool changed = false;

      foreach (ISymbol p in parent.Flatten().Where(p => !(p is GroupSymbol)))
        changed |= AddAllowedChildSymbolToDictionaries(p, child, argumentIndex);

      if (changed) {
        ClearCaches();
        OnChanged();
      }
    }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:11,代码来源:SymbolicExpressionGrammarBase.cs

示例2: SetSubtreeCount

    public virtual void SetSubtreeCount(ISymbol symbol, int minimumSubtreeCount, int maximumSubtreeCount) {
      var symbols = symbol.Flatten().Where(s => !(s is GroupSymbol));
      if (symbols.Any(s => s.MinimumArity > minimumSubtreeCount)) throw new ArgumentException("Invalid minimum subtree count " + minimumSubtreeCount + " for " + symbol);
      if (symbols.Any(s => s.MaximumArity < maximumSubtreeCount)) throw new ArgumentException("Invalid maximum subtree count " + maximumSubtreeCount + " for " + symbol);

      foreach (ISymbol s in symbols)
        SetSubTreeCountInDictionaries(s, minimumSubtreeCount, maximumSubtreeCount);

      ClearCaches();
      OnChanged();
    }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:11,代码来源:SymbolicExpressionGrammarBase.cs

示例3: RemoveSymbol

    public virtual void RemoveSymbol(ISymbol symbol) {
      foreach (var s in symbol.Flatten()) {
        symbols.Remove(s.Name);
        allowedChildSymbols.Remove(s.Name);
        for (int i = 0; i < GetMaximumSubtreeCount(s); i++)
          allowedChildSymbolsPerIndex.Remove(Tuple.Create(s.Name, i));
        symbolSubtreeCount.Remove(s.Name);

        foreach (var parent in Symbols) {
          List<string> allowedChilds;
          if (allowedChildSymbols.TryGetValue(parent.Name, out allowedChilds))
            allowedChilds.Remove(s.Name);

          for (int i = 0; i < GetMaximumSubtreeCount(parent); i++) {
            if (allowedChildSymbolsPerIndex.TryGetValue(Tuple.Create(parent.Name, i), out allowedChilds))
              allowedChilds.Remove(s.Name);
          }
        }
        suppressEvents = true;
        foreach (var groupSymbol in Symbols.OfType<GroupSymbol>())
          groupSymbol.SymbolsCollection.Remove(symbol);
        suppressEvents = false;
      }
      ClearCaches();
    }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:25,代码来源:SymbolicExpressionGrammarBase.cs

示例4: AddSymbol

 public virtual void AddSymbol(ISymbol symbol) {
   if (ContainsSymbol(symbol)) throw new ArgumentException("Symbol " + symbol + " is already defined.");
   foreach (var s in symbol.Flatten()) {
     symbols.Add(s.Name, s);
     int maxSubTreeCount = Math.Min(s.MinimumArity + 1, s.MaximumArity);
     symbolSubtreeCount.Add(s.Name, Tuple.Create(s.MinimumArity, maxSubTreeCount));
   }
   ClearCaches();
 }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:9,代码来源:SymbolicExpressionGrammarBase.cs

示例5: ChangeDuplicateSymbolNames

 private void ChangeDuplicateSymbolNames(ISymbol symbol) {
   foreach (var s in symbol.Flatten()) {
     var originalSymbolName = s.Name;
     int i = 1;
     while (Content.ContainsSymbol(s)) {
       s.Name = originalSymbolName + i;
       i++;
     }
   }
 }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:10,代码来源:SymbolicExpressionGrammarEditorView.cs

示例6: UpdateGrammerConstraintsForClonedSymbol

 private void UpdateGrammerConstraintsForClonedSymbol(ISymbol symbol, Cloner cloner) {
   foreach (var s in symbol.Flatten().Where(x => !(x is GroupSymbol))) {
     if (!cloner.ClonedObjectRegistered(s)) throw new InvalidOperationException();
     var clone = cloner.Clone(s);
     Content.SetSubtreeCount(clone, Content.GetMinimumSubtreeCount(s), Content.GetMaximumSubtreeCount(s));
     foreach (var childSymbol in Content.GetAllowedChildSymbols(s)) {
       var newChildSymbol = childSymbol;
       if (cloner.ClonedObjectRegistered(childSymbol)) newChildSymbol = cloner.Clone(childSymbol);
       Content.AddAllowedChildSymbol(clone, newChildSymbol);
     }
     for (int i = 0; i < Content.GetMaximumSubtreeCount(s); i++) {
       foreach (var childSymbol in Content.GetAllowedChildSymbols(s, i)) {
         var newChildSymbol = childSymbol;
         if (cloner.ClonedObjectRegistered(childSymbol)) newChildSymbol = cloner.Clone(childSymbol);
         Content.AddAllowedChildSymbol(clone, newChildSymbol, i);
       }
     }
   }
 }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:19,代码来源:SymbolicExpressionGrammarEditorView.cs

示例7: DeregisterSymbolEvents

    private void DeregisterSymbolEvents(ISymbol symbol) {
      foreach (var s in symbol.Flatten()) {
        s.NameChanging -= new EventHandler<CancelEventArgs<string>>(Symbol_NameChanging);
        s.NameChanged -= new EventHandler(Symbol_NameChanged);

        var groupSymbol = s as GroupSymbol;
        if (groupSymbol != null) DeregisterGroupSymbolEvents(groupSymbol);
        else s.Changed -= new EventHandler(Symbol_Changed);
      }
    }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:10,代码来源:SymbolicExpressionGrammar.cs


注:本文中的ISymbol.Flatten方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。