public virtual void Seek(int index)
{
if (index == currentCharIndex)
{
return;
}
if (index > currentCharIndex)
{
Sync(index - currentCharIndex);
index = Math.Min(index, BufferStartIndex + n - 1);
}
// index == to bufferStartIndex should set p to 0
int i = index - BufferStartIndex;
if (i < 0)
{
throw new ArgumentException("cannot seek to negative index " + index);
}
else
{
if (i >= n)
{
throw new NotSupportedException("seek to index outside buffer: " + index + " not in " + BufferStartIndex + ".." + (BufferStartIndex + n));
}
}
p = i;
currentCharIndex = index;
if (p == 0)
{
lastChar = lastCharBufferStart;
}
else
{
lastChar = data[p - 1];
}
}