Esempio n. 1
0
        private LineSearchResult LineSearch(int index)
        {
            int lo = 0;
            int hi = this.lineBreaks.Length - 1;

            while (lo <= hi)
            {
                int  mid           = (lo + hi) / 2;
                uint probe         = this.lineBreaks[mid];
                int  probePosition = EncodedLineBreaks.DecodePosition(probe);
                if (probePosition < index)
                {
                    lo = mid + 1;
                }
                else if (probePosition > index)
                {
                    hi = mid - 1;
                }
                else
                {
                    if (EncodedLineBreaks.IsSingleCharLineBreak(probe))
                    {
                        return(LineSearchResult.SingleCharLineBreak);
                    }
                    else
                    {
                        return(LineSearchResult.DoubleCharLineBreak);
                    }
                }
            }
            return(LineSearchResult.NotLineBreak);
        }
Esempio n. 2
0
        public int EndOfLineBreak(int index)
        {
            uint encodedPosition = this.lineBreaks[index];
            int  decodedPosition = EncodedLineBreaks.DecodePosition(encodedPosition);

            if (EncodedLineBreaks.IsSingleCharLineBreak(encodedPosition))
            {
                return(decodedPosition + 1);
            }
            else
            {
                return(decodedPosition + 2);
            }
        }
Esempio n. 3
0
 public int StartOfLineBreak(int index)
 {
     // strip MSB
     return(EncodedLineBreaks.DecodePosition(this.lineBreaks[index]));
 }