Version 3.3.1.2

Buffer<T> class

Namespace: Sirenix.Serialization
Assembly: Sirenix.Serialization
public sealed class Buffer<T> : IDisposable
Provides a way of claiming and releasing cached array buffers.
Inheritance
  • System.Object
  • Buffer<T>
See Also
  • System.IDisposable

Type Parameters

T

The element type of the array to buffer.

Properties

Array
Gets the buffered array.
public T[] Array { get; }
Exceptions
System.InvalidOperationException

Cannot access a buffer while it is freed.

Count
Gets the total element count of the buffered array. This will always be a power of two.
public int Count { get; }
Exceptions
System.InvalidOperationException

Cannot access a buffer while it is freed.

IsFree
Gets a value indicating whether this buffer is free.
public bool IsFree { get; }

Methods

Claim(Int32)
Claims a buffer with the specified minimum capacity. Note: buffers always have a capacity equal to or larger than 256.
public static Buffer<T> Claim(int minimumCapacity)
Parameters
System.Int32 minimumCapacity

The minimum capacity.

Returns
Buffer<T>

A buffer which has a capacity equal to or larger than the specified minimum capacity.

Exceptions
System.ArgumentException

Requested size of buffer must be larger than 0.

Dispose()
Frees this buffer.
public void Dispose()
Free()
Frees this buffer.
public void Free()
Free(Buffer<T>)
Frees the specified buffer.
public static void Free(Buffer<T> buffer)
Parameters
Buffer<T> buffer

The buffer to free.

Exceptions
System.ArgumentNullException

The buffer argument is null.