public LongRange GetNextBufferRange(long offset)
{
if (offset >= this.PutioFile.Size)
return null;
lock (this.RangeCollection)
{
LongRange BufferThis = new LongRange(0, this.PutioFile.Size);
int index = this.RangeCollection.BinaryIndexSearch(offset);
if (index < 0)
{
BufferThis.Start = offset;
index = this.RangeCollection.Bisect(offset);
if (index < this.RangeCollection.RangeSet.Count)
BufferThis.End = this.RangeCollection.RangeSet.ElementAt(index).Start;
else
BufferThis.End = this.PutioFile.Size;
}
else
{
return this.GetNextBufferRange(this.RangeCollection.RangeSet.ElementAt(index).End);
}
return BufferThis;
}
}