/// <summary> /// performs exactly one iteration of the algorithm /// </summary> public override void DoOneRun() { if (Finished) { throw new GSTException("algorithm is finished"); } var watch = Stopwatch.StartNew(); var listMatches = new List <Tile <T> >(); LastMaximumMatch = MinimumMatchLength; // for every token in A that is unmarked foreach (var tA in ListA.Where(t => !t.Marked)) { var tokA = tA; // CLOSURE int indA = ListA.IndexOf(tokA); // for every token in B that is unmarked and matches tokA foreach (var tB in ListB.Where(t => !t.Marked).Where(tokA.EqualsTokenValue)) { //counter++; var tokB = tB; // CLOSURE int indB = ListB.IndexOf(tokB); int matchLength = CalculateMatchLength(indA, indB); if (matchLength >= LastMaximumMatch) { var tile = AbstractGSTAlgorithm.CreateTile(ListA, indA, indB, matchLength); AddTileToMatchList(listMatches, matchLength, tile); } } // foreach in B } // foreach in A foreach (var tile in listMatches) { MarkTileAsMatched(tile); ListTiles.Add(tile); } TilesMatchedInLastRun = listMatches; //Console.WriteLine("one run({1}) took {0} ms", watch.ElapsedMilliseconds, counter); }
/// <summary> /// compares two lists of HashingEntity objects /// </summary> /// <param name="listA"></param> /// <param name="listB"></param> private void CompareLists(IList <HashingEntity> listA, IList <HashingEntity> listB) { foreach (var entityA in listA) { var indA = ListA.IndexOf(entityA.Tokens[0]); //Console.WriteLine("indexA: " + indA); foreach (var entityB in listB) { var indB = ListB.IndexOf(entityB.Tokens[0]); int matchLength = CalculateMatchLength(indA, indB); //Console.WriteLine("indexB: {0}, ML: {1}", indB, matchLength); if (matchLength >= LastMaximumMatch) { var tile = AbstractGSTAlgorithm.CreateTile(ListA, indA, indB, matchLength); AddTileToMatchList(MatchesList, matchLength, tile); } } // foreach in B } // foreach in A }