SetMatch() 공개 메소드

public SetMatch ( int start, int length ) : void
start int
length int
리턴 void
예제 #1
0
파일: Engine.cs 프로젝트: sumpacle/src
        private void GetLongestSourceMatch(DiffState curItem, int destIndex, int destEnd, int sourceStart, int sourceEnd)
        {
            var maxDestLength = (destEnd - destIndex) + 1;
            var curLength     = 0;
            var curBestLength = 0;
            var curBestIndex  = -1;
            var maxLength     = 0;

            for (var sourceIndex = sourceStart; sourceIndex <= sourceEnd; sourceIndex++)
            {
                maxLength = Math.Min(maxDestLength, (sourceEnd - sourceIndex) + 1);
                if (maxLength <= curBestLength)
                {
                    //No chance to find a longer one any more
                    break;
                }
                curLength = GetSourceMatchLength(destIndex, sourceIndex, maxLength);
                if (curLength > curBestLength)
                {
                    //This is the best match so far
                    curBestIndex  = sourceIndex;
                    curBestLength = curLength;
                }
                //jump over the match
                sourceIndex += curBestLength;
            }
            //DiffState cur = _stateList.GetByIndex(destIndex);
            if (curBestIndex == -1)
            {
                curItem.SetNoMatch();
            }
            else
            {
                curItem.SetMatch(curBestIndex, curBestLength);
            }
        }
예제 #2
0
 private void GetLongestSourceMatch(DiffState curItem, int destIndex,int destEnd, int sourceStart,int sourceEnd)
 {
     var maxDestLength = (destEnd - destIndex) + 1;
     var curLength = 0;
     var curBestLength = 0;
     var curBestIndex = -1;
     var maxLength = 0;
     for (var sourceIndex = sourceStart; sourceIndex <= sourceEnd; sourceIndex++)
     {
         maxLength = Math.Min(maxDestLength,(sourceEnd - sourceIndex) + 1);
         if (maxLength <= curBestLength)
         {
             //No chance to find a longer one any more
             break;
         }
         curLength = GetSourceMatchLength(destIndex,sourceIndex,maxLength);
         if (curLength > curBestLength)
         {
             //This is the best match so far
             curBestIndex = sourceIndex;
             curBestLength = curLength;
         }
         //jump over the match
         sourceIndex += curBestLength;
     }
     //DiffState cur = _stateList.GetByIndex(destIndex);
     if (curBestIndex == -1)
     {
         curItem.SetNoMatch();
     }
     else
     {
         curItem.SetMatch(curBestIndex, curBestLength);
     }
 }