public void CopyTo(RingBuffer <T> dst, int length) { var src = this; if (src.AvailableRead < length || dst.AvailableWrite < length) { throw new IndexOutOfRangeException(); } int THIS_MASK = src.mask; int THAT_MASK = dst.mask; for (var n = 0; n < length; n++) { src.buffer[(src.posWrite + n) & THIS_MASK] = dst.buffer[(dst.posRead + n) & THAT_MASK]; } src.posWrite = (src.posWrite + length) & THIS_MASK; dst.posRead = (dst.posRead + length) & THAT_MASK; src.OffsetWrite(+length); dst.OffsetWrite(-length); }
public void CopyTo(RingBuffer <T> dst) => CopyTo(dst, AvailableRead);