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


C# ISymbolicExpressionTreeNode.IndexOfSubtree方法代码示例

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


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

示例1: Modify

 /// <summary>
 /// Remove, Replace or Insert subtrees
 /// </summary>
 /// <param name="tree">The symbolic expression tree</param>
 /// <param name="parent">The insertion point (ie, the parent node who will receive a new child)</param>
 /// <param name="oldChild">The subtree to be replaced</param>
 /// <param name="newChild">The replacement subtree</param>
 /// <param name="removeSubtree">Flag used to indicate if whole subtrees should be removed (default behavior), or just the subtree root</param>
 private void Modify(ISymbolicExpressionTree tree, ISymbolicExpressionTreeNode parent,
   ISymbolicExpressionTreeNode oldChild, ISymbolicExpressionTreeNode newChild, bool removeSubtree = true) {
   if (oldChild == null && newChild == null)
     throw new ArgumentNullException("Cannot deduce operation type from the arguments. Please provide non null operands.");
   if (oldChild == null) {
     // insertion operation
     parent.AddSubtree(newChild);
     newChild.Parent = parent;
   } else if (newChild == null) {
     // removal operation
     parent.RemoveSubtree(parent.IndexOfSubtree(oldChild));
     if (!removeSubtree) {
       for (int i = oldChild.SubtreeCount - 1; i >= 0; --i) {
         var subtree = oldChild.GetSubtree(i);
         oldChild.RemoveSubtree(i);
         parent.AddSubtree(subtree);
       }
     }
   } else {
     // replacement operation
     var replacementIndex = parent.IndexOfSubtree(oldChild);
     parent.RemoveSubtree(replacementIndex);
     parent.InsertSubtree(replacementIndex, newChild);
     newChild.Parent = parent;
     if (changedNodes.ContainsKey(oldChild)) {
       changedNodes.Add(newChild, changedNodes[oldChild]); // so that on double click the original node is restored
       changedNodes.Remove(oldChild);
     } else {
       changedNodes.Add(newChild, oldChild);
     }
   }
   treeState = IsValid(tree) ? TreeState.Valid : TreeState.Invalid;
   switch (treeState) {
     case TreeState.Valid:
       this.grpViewHost.Enabled = true;
       UpdateModel(Content.Model.SymbolicExpressionTree);
       break;
     case TreeState.Invalid:
       this.grpViewHost.Enabled = false;
       break;
   }
 }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:50,代码来源:InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs

示例2: CutPoint

 public CutPoint(ISymbolicExpressionTreeNode parent, ISymbolicExpressionTreeNode child) {      
   this.Parent = parent;
   this.Child = child;
   this.ChildIndex = parent.IndexOfSubtree(child);
   this.grammar = parent.Grammar;
 }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:6,代码来源:CutPoint.cs


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