Exemplo n.º 1
0
        protected void Merge(DFAMatrix dfaMatrixA, DFAMatrix dfaMatrixB)
        {
            DFANodes = new List <DFANode>(Compare.Max <int>(dfaMatrixA.DFANodes.Count, dfaMatrixB.DFANodes.Count) + 128);

            DFANodes.Add(new DFANode());
            DFANodes.Add(new DFANode());

            DFAMatrixCache lCache = new DFAMatrixCache(DFANodes.Capacity);

            Product(dfaMatrixA, 1, dfaMatrixB, 1, lCache);
        }
Exemplo n.º 2
0
        protected void Product(DFAMatrix dfaLeft, int left, DFAMatrix dfaRight, int right, DFAMatrixCache cache)
        {
            int lState = DFANodes.Count - 1;

            AttributeUnion(DFANodes[lState], dfaLeft.DFANodes[left], dfaRight.DFANodes[right]);

            for (int c = 0; c != 4; c++)
            {
                int lNextL = dfaLeft.DFANodes[left][c];
                int lNextR = dfaRight.DFANodes[right][c];

                if ((lNextL != 0) || (lNextR != 0))
                {
                    int lNewValue = cache.Search(lNextL, lNextR);

                    if (lNewValue == 0)
                    {
                        // create it
                        int lLastState = DFANodes.Count;
                        //DFANodes.Add(new DFANode(DFANodes[lState].Level + 1));
                        DFANodes.Add(new DFANode());

                        cache.Add(lNextL, lNextR, lLastState);

                        DFANodes[lState][c] = lLastState;

                        Product(dfaLeft, lNextL, dfaRight, lNextR, cache);
                    }
                    else
                    {
                        // link to it
                        DFANodes[lState][c] = lNewValue;
                    }
                }
                else
                {
                    DFANodes[lState][c] = 0;
                }
            }
        }
Exemplo n.º 3
0
        protected void Product(DFAMatrix dfaLeft, int left, DFAMatrix dfaRight, int right, DFAMatrixCache cache)
        {
            int lState = DFANodes.Count - 1;

            AttributeUnion(DFANodes[lState], dfaLeft.DFANodes[left], dfaRight.DFANodes[right]);

            for (int c = 0; c != 4; c++)
            {
                int lNextL = dfaLeft.DFANodes[left][c];
                int lNextR = dfaRight.DFANodes[right][c];

                if ((lNextL != 0) || (lNextR != 0))
                {
                    int lNewValue = cache.Search(lNextL, lNextR);

                    if (lNewValue == 0)
                    {
                        // create it
                        int lLastState = DFANodes.Count;
                        //DFANodes.Add(new DFANode(DFANodes[lState].Level + 1));
                        DFANodes.Add(new DFANode());

                        cache.Add(lNextL, lNextR, lLastState);

                        DFANodes[lState][c] = lLastState;

                        Product(dfaLeft, lNextL, dfaRight, lNextR, cache);
                    }
                    else
                    {
                        // link to it
                        DFANodes[lState][c] = lNewValue;
                    }
                }
                else
                {
                    DFANodes[lState][c] = 0;
                }
            }
        }
Exemplo n.º 4
0
        protected void Merge(DFAMatrix dfaMatrixA, DFAMatrix dfaMatrixB)
        {
            DFANodes = new List<DFANode>(Compare.Max<int>(dfaMatrixA.DFANodes.Count, dfaMatrixB.DFANodes.Count) + 128);

            DFANodes.Add(new DFANode());
            DFANodes.Add(new DFANode());

            DFAMatrixCache lCache = new DFAMatrixCache(DFANodes.Capacity);

            Product(dfaMatrixA, 1, dfaMatrixB, 1, lCache);
        }