Пример #1
0
        public long IndexOfElement(ByteString targetBytes, long fromIndex)
        {
            if (_closed)
            {
                throw new IllegalStateException("closed");
            }

            while (true)
            {
                long result = _easyBuffer.IndexOfElement(targetBytes, fromIndex);
                if (result != -1)
                {
                    return(result);
                }

                long lastBufferSize = _easyBuffer.Size;
                if (_source.Read(_easyBuffer, Segment.SIZE) == -1)
                {
                    return(-1L);
                }

                // Keep searching, picking up from where we left off.
                fromIndex = Math.Max(fromIndex, lastBufferSize);
            }
        }