Example #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);
        }
Example #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);
            }
        }