Ejemplo n.º 1
0
 private void populateGrid()
 {
     setZeros();
     for (int i = 1; i <= left.Length; i++)
     {
         for (int j = 1; j <= right.Length; j++)
         {
             bool isMatch;
             int  localMax;
             if (left[i - 1] == right[j - 1])
             {
                 isMatch  = true;
                 localMax = 1 + tally[i - 1, j - 1].LocalMax;
             }
             else
             {
                 isMatch  = false;
                 localMax = Math.Max(tally[i, j - 1].LocalMax, tally[i - 1, j].LocalMax);
             }
             tally[i, j] = new Tally(isMatch, localMax);
         }
     }
 }
Ejemplo n.º 2
0
 public StringDiff(string left, string right)
 {
     this.left  = left.ToCharArray().Select(c => c.ToString()).ToArray();
     this.right = right.ToCharArray().Select(c => c.ToString()).ToArray();
     tally      = new Tally[left.Length + 1, right.Length + 1];
 }