Beispiel #1
0
        /// <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);
        }
Beispiel #2
0
        public override void DoOneRun()
        {
            if (Finished)
            {
                throw new GSTException("algorithm is finished");
            }


            // can not do in constructor, because client code may change MML after constructor
            if (!initialized)
            {
                InitializeHashes();

                /*
                 * for (int i = 0; i < ListA.Count; i++)
                 * {
                 *  cLogger.DebugFormat("A: {0}, B:{1}", ListA[i].GetHashCode(), ListB[i].GetHashCode());
                 * }
                 * /* */
            }

            MatchesList = new List <Tile <T> >();

            LastMaximumMatch = MinimumMatchLength;

            // because of the minimization performed previously
            // every element in A is also present in B!
            foreach (KeyValuePair <Int32, IList <HashingEntity> > kvpA in HashesA)
            {
                CompareLists(kvpA.Value, HashesB[kvpA.Key]);
            }

            foreach (var tile in MatchesList)
            {
                MarkTileAsMatched(tile);
                ListTiles.Add(tile);
            }

            TilesMatchedInLastRun = MatchesList;
        }