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


C# StatementList.Clone方法代码示例

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


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

示例1: VisitStatementList

 public virtual Differences VisitStatementList(StatementList list1, StatementList list2,
   out StatementList changes, out StatementList deletions, out StatementList insertions){
   changes = list1 == null ? null : list1.Clone();
   deletions = list1 == null ? null : list1.Clone();
   insertions = list1 == null ? new StatementList() : list1.Clone();
   //^ assert insertions != null;
   Differences differences = new Differences();
   for (int j = 0, n = list2 == null ? 0 : list2.Count; j < n; j++){
     //^ assert list2 != null;
     Statement nd2 = list2[j];
     if (nd2 == null) continue;
     insertions.Add(null);
   }
   TrivialHashtable savedDifferencesMapFor = this.differencesMapFor;
   this.differencesMapFor = null;
   TrivialHashtable matchedNodes = new TrivialHashtable();
   for (int i = 0, k = 0, n = list1 == null ? 0 : list1.Count; i < n; i++){
     //^ assert list1 != null && changes != null && deletions != null;
     Statement nd1 = list1[i]; 
     if (nd1 == null) continue;
     Differences diff;
     int j;
     Statement nd2 = this.GetClosestMatch(nd1, list1, list2, i, ref k, matchedNodes, out diff, out j);
     if (nd2 == null || diff == null){Debug.Assert(nd2 == null && diff == null); continue;}
     matchedNodes[nd1.UniqueKey] = nd1;
     matchedNodes[nd2.UniqueKey] = nd2;
     changes[i] = diff.Changes as Statement;
     deletions[i] = diff.Deletions as Statement;
     insertions[i] = diff.Insertions as Statement;
     insertions[n+j] = nd1; //Records the position of nd2 in list2 in case the change involved a permutation
     Debug.Assert(diff.Changes == changes[i] && diff.Deletions == deletions[i] && diff.Insertions == insertions[i]);
     differences.NumberOfDifferences += diff.NumberOfDifferences;
     differences.NumberOfSimilarities += diff.NumberOfSimilarities;
   }
   //Find deletions
   for (int i = 0, n = list1 == null ? 0 : list1.Count; i < n; i++){
     //^ assert list1 != null && changes != null && deletions != null;
     Statement nd1 = list1[i]; 
     if (nd1 == null) continue;
     if (matchedNodes[nd1.UniqueKey] != null) continue;
     changes[i] = null;
     deletions[i] = nd1;
     insertions[i] = null;
     differences.NumberOfDifferences += 1;
   }
   //Find insertions
   for (int j = 0, n = list1 == null ? 0 : list1.Count, m = list2 == null ? 0 : list2.Count; j < m; j++){
     //^ assert list2 != null;
     Statement nd2 = list2[j]; 
     if (nd2 == null) continue;
     if (matchedNodes[nd2.UniqueKey] != null) continue;
     insertions[n+j] = nd2;  //Records nd2 as an insertion into list1, along with its position in list2
     differences.NumberOfDifferences += 1; //REVIEW: put the size of the tree here?
   }
   if (differences.NumberOfDifferences == 0){
     changes = null;
     deletions = null;
     insertions = null;
   }
   this.differencesMapFor = savedDifferencesMapFor;
   return differences;
 }
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:62,代码来源:Comparer.cs

示例2: Visit

            private StatementList Visit(StatementList statementList)
            {
                Contract.Requires(this.Depth >= 0);
                Contract.Ensures(this.Depth >= -1);

                if (statementList == null) return null;

                statementList = statementList.Clone();
                for (int i = 0; i < statementList.Count; i++)
                {
                    statementList[i] = Visit(statementList[i]);
                    if (this.Depth < 0) return statementList; // stop
                }

                return statementList;
            }
开发者ID:Yatajga,项目名称:CodeContracts,代码行数:16,代码来源:HelperMethods.cs


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