internal void LeaveOnlyBest(string string1, string string2, StringManager.StringNorm norm) { var all = new List <Point[]>(_equalsMy); all.AddRange(_equalsInheriredLeft); all.AddRange(_equalsInheriredTop); if (all.Count < 2) { return; } int best = int.MaxValue, pos = 0, bestpos = -1; foreach (var item in all) { int curr = norm(string1, string2, item); if (curr < best) { best = curr; bestpos = pos; } pos++; } var bestEq = all[bestpos]; var toAdd = (bestpos < _equalsMy.Count) ? _equalsMy : ((bestpos < _equalsMy.Count + _equalsInheriredLeft.Count) ? _equalsInheriredLeft : _equalsInheriredTop); _equalsMy.Clear(); _equalsInheriredLeft.Clear(); _equalsInheriredTop.Clear(); toAdd.Add(bestEq); }
internal void WriteAll(string string1, string string2, StringManager.StringNorm norm, TextWriter writer) { var all = new List <Point[]>(_equalsMy); all.AddRange(_equalsInheriredLeft); all.AddRange(_equalsInheriredTop); foreach (var item in all) { writer.Write(SubString(string1, item)); writer.Write(" : "); writer.WriteLine(norm(string1, string2, item)); } }
internal Point[] BestEquality(string string1, string string2, StringManager.StringNorm norm) { int best = int.MaxValue, pos = 0, bestpos = -1; var all = new List <Point[]>(_equalsMy); all.AddRange(_equalsInheriredLeft); all.AddRange(_equalsInheriredTop); foreach (var item in all) { int curr = norm(string1, string2, item); if (curr < best) { best = curr; bestpos = pos; } pos++; } return(bestpos > -1 ? all[bestpos] : System.Array.Empty <Point>()); }
internal string Best(string string1, string string2, StringManager.StringNorm norm) { var best = BestEquality(string1, string2, norm); return(best != null?SubString(string1, best) : null); }