예제 #1
0
        Snake Calculate(VState VState, int k, int d, string[] strA, int a0, int N, string[] strB, int b0, int M)
        {
            bool down = (k == -d || (k != d && VState[k - 1] < VState[k + 1]));

            int xStart = down ? VState[k + 1] : VState[k - 1];
            int yStart = xStart - (down ? k + 1 : k - 1);

            int xEnd = down ? xStart : xStart + 1;
            int yEnd = xEnd - k;

            int snake = 0;

            while (xEnd < N && yEnd < M && strA[xEnd + a0] == strB[yEnd + b0])
            {
                xEnd++; yEnd++; snake++;
            }

            XStart         = xStart + a0;
            YStart         = yStart + b0;
            ADeleted       = down ? 0 : 1;
            BInserted      = down ? 1 : 0;
            DiagonalLength = snake;

            RemoveStubs(a0, N, b0, M);

            return(this);
        }
예제 #2
0
        public VState CreateCopy(int d, int delta)
        {
            // Debug.Assert( !( isForward && delta != 0 ) );

            if (d == 0)
            {
                d++;
            }

            VState localV = new VState();

            localV.m_max   = d;
            localV.m_delta = delta;
            localV.m_array = new int[2 * d + 1];

            if (d <= m_max)
            {
                Array.Copy(m_array, (m_max - m_delta) - (localV.m_max - localV.m_delta), localV.m_array, 0, localV.m_array.Length);
            }
            else
            {
                throw new NotImplementedException("V.CreateCopy");
                //Debug.Assert( false );
                //Debug.Assert( _Delta == 0 );
                //Marshal.Copy( _Array, 0, new IntPtr( po + d - _Max ), _Array.Length );
            }

            return(localV);
        }
예제 #3
0
        public Snake(int a0, int N, int b0, int M, bool forward, int delta, VState VState, int k, int d, string[] strA, string[] strB)
        {
            DELTA = delta;

            Calculate(VState, k, d, strA, a0, N, strB, b0, M);
        }