@@ -81,8 +81,15 @@ public ArrayBufferWriter(int initialCapacity)
/// Clears the data written to the underlying buffer.
/// </summary>
/// <remarks>
/// You must clear the <see cref="ArrayBufferWriter{T}"/> before trying to re-use it.
/// <para>
/// You must reset or clear the <see cref="ArrayBufferWriter{T}"/> before trying to re-use it.
/// </para>
/// <para>
/// The <see cref="ResetWrittenCount"/> method is faster since it only sets to zero the writer's index
/// while the <see cref="Clear"/> method additionally zeroes the content of the underlying buffer.
/// </para>
/// </remarks>
/// <seealso cref="ResetWrittenCount"/>
publicvoidClear()
{
Debug.Assert(_buffer.Length>=_index);
...
...
@@ -90,6 +97,20 @@ public void Clear()
_index=0;
}
/// <summary>
/// Resets the data written to the underlying buffer without zeroing its content.
/// </summary>
/// <remarks>
/// <para>
/// You must reset or clear the <see cref="ArrayBufferWriter{T}"/> before trying to re-use it.
/// </para>
/// <para>
/// If you reset the writer using the <see cref="ResetWrittenCount"/> method, the underlying buffer will not be cleared.
/// </para>
/// </remarks>
/// <seealso cref="Clear"/>
publicvoidResetWrittenCount()=>_index=0;
/// <summary>
/// Notifies <see cref="IBufferWriter{T}"/> that <paramref name="count"/> amount of data was written to the output <see cref="Span{T}"/>/<see cref="Memory{T}"/>
/// </summary>
...
...
@@ -121,13 +142,21 @@ public void Advance(int count)
/// Thrown when <paramref name="sizeHint"/> is negative.
/// </exception>
/// <remarks>
/// <para>
/// This will never return an empty <see cref="Memory{T}"/>.
/// </remarks>
/// <remarks>
/// </para>
/// <para>
/// There is no guarantee that successive calls will return the same buffer or the same-sized buffer.
/// </remarks>
/// <remarks>
/// </para>
/// <para>
/// You must request a new buffer after calling Advance to continue writing more data and cannot write to a previously acquired buffer.
/// </para>
/// <para>
/// If you reset the writer using the <see cref="ResetWrittenCount"/> method, this method may return a non-cleared <see cref="Memory{T}"/>.
/// </para>
/// <para>
/// If you clear the writer using the <see cref="Clear"/> method, this method will return a <see cref="Memory{T}"/> with its content zeroed.
/// </para>
/// </remarks>
publicMemory<T>GetMemory(intsizeHint=0)
{
...
...
@@ -144,13 +173,21 @@ public Memory<T> GetMemory(int sizeHint = 0)
/// Thrown when <paramref name="sizeHint"/> is negative.
/// </exception>
/// <remarks>
/// <para>
/// This will never return an empty <see cref="Span{T}"/>.
/// </remarks>
/// <remarks>
/// </para>
/// <para>
/// There is no guarantee that successive calls will return the same buffer or the same-sized buffer.
/// </remarks>
/// <remarks>
/// </para>
/// <para>
/// You must request a new buffer after calling Advance to continue writing more data and cannot write to a previously acquired buffer.
/// </para>
/// <para>
/// If you reset the writer using the <see cref="ResetWrittenCount"/> method, this method may return a non-cleared <see cref="Span{T}"/>.
/// </para>
/// <para>
/// If you clear the writer using the <see cref="Clear"/> method, this method will return a <see cref="Span{T}"/> with its content zeroed.