Esempio n. 1
0
        public static int Seek(ReadCursor begin, ReadCursor end, out ReadCursor result, byte byte0, byte byte1)
        {
            var enumerator = new SegmentEnumerator(begin, end);

            while (enumerator.MoveNext())
            {
                var segmentPart = enumerator.Current;
                var segment     = segmentPart.Segment;
                var span        = segment.Memory.Span.Slice(segmentPart.Start, segmentPart.Length);

                int index1 = span.IndexOfVectorized(byte0);
                int index2 = span.IndexOfVectorized(byte1);

                var index = MinIndex(index1, index2);
                if (index != -1)
                {
                    result = new ReadCursor(segment, segmentPart.Start + index);
                    return(span[index]);
                }
            }

            result = end;
            return(-1);
        }
Esempio n. 2
0
 /// <summary>
 ///
 /// </summary>
 public BufferEnumerator(ReadCursor start, ReadCursor end)
 {
     _segmentEnumerator = new SegmentEnumerator(start, end);
     _current           = default(Buffer <byte>);
 }