Пример #1
0
 internal ReadCursor(BufferSegment segment, int index)
 {
     _segment = segment;
     _index   = index;
 }
Пример #2
0
        public static BufferSegment Clone(ReadCursor beginBuffer, ReadCursor endBuffer, out BufferSegment lastSegment)
        {
            var beginOrig = beginBuffer.Segment;
            var endOrig   = endBuffer.Segment;

            if (beginOrig == endOrig)
            {
                lastSegment = new BufferSegment(beginOrig.Buffer, beginBuffer.Index, endBuffer.Index);
                return(lastSegment);
            }

            var beginClone = new BufferSegment(beginOrig.Buffer, beginBuffer.Index, beginOrig.End);
            var endClone   = beginClone;

            beginOrig = beginOrig.Next;

            while (beginOrig != endOrig)
            {
                endClone.Next = new BufferSegment(beginOrig.Buffer, beginOrig.Start, beginOrig.End);

                endClone  = endClone.Next;
                beginOrig = beginOrig.Next;
            }

            lastSegment   = new BufferSegment(endOrig.Buffer, endOrig.Start, endBuffer.Index);
            endClone.Next = lastSegment;

            return(beginClone);
        }
Пример #3
0
 internal ReadCursor(BufferSegment segment)
 {
     _segment = segment;
     _index   = segment?.Start ?? 0;
 }