2using System.Collections;
3using System.Collections.Generic;
33 BitArray Processed =
new BitArray(c1p * c2p);
34 LinkedList<State<T>> Current =
new LinkedList<State<T>>();
35 LinkedList<State<T>> Next =
new LinkedList<State<T>>();
36 LinkedList<State<T>> NextNext =
new LinkedList<State<T>>();
37 LinkedList<State<T>> Temp;
52 if (P.i1 == c1 && P.i2 == c2)
55 i = P.i1 + P.i2 * c1p;
62 if (!Processed[i + c1p])
81 if (!Processed[i + 1])
98 if (b1 && b2 && S1[P.i1].Equals(S2[P.i2]))
100 if (!Processed[i + 1 + c1p])
112 if (Q.i1 == c1 && Q.i2 == c2)
121 if (Current.First is
null)
125 if (Next.First is
null)
136 P = Current.Last.Value;
137 Current.RemoveLast();
140 LinkedList<T> SameOp =
new LinkedList<T>();
141 LinkedList<Step<T>> Steps =
new LinkedList<Step<T>>();
149 while (!((Q = P.Prev) is
null))
154 SameOp.CopyTo(Symbols, 0);
155 Steps.AddFirst(
new Step<T>(Symbols, First.i1, First.i2, Op));
167 SameOp.AddFirst(S1[P.i1 - 1]);
171 SameOp.AddFirst(S2[P.i2 - 1]);
181 SameOp.CopyTo(Symbols, 0);
182 Steps.AddFirst(
new Step<T>(Symbols, First.i1, First.i2, Op));
186 Steps.CopyTo(Result, 0);
191 private class State<T>
196 public State<T> Prev;
207 return Analyze(s1.ToCharArray(), s2.ToCharArray());
228 return Text.Replace(
"\r\n",
"\n").Replace(
'\r',
'\n').Split(
'\n');
Computes the difference between two sequences of symbols.
static EditScript< string > AnalyzeRows(string Text1, string Text2)
Analyzes two texts, estimating the difference between them, as a sequence of rows.
static string[] ExtractRows(string Text)
Extracts the rows from a text.
static EditScript< char > AnalyzeStrings(string s1, string s2)
Analyzes two text strings, estimating the difference between them.
static EditScript< T > Analyze< T >(T[] S1, T[] S2)
Analyzes two sequences of symbols to estimate the difference between them.
Represents an Edit-script, converting one sequence of symbols to another.
Represents a sub-sequence of symbols.
EditOperation
Type of edit-operation