mirror of https://github.com/ogoun/Zero.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
597 B
33 lines
597 B
using System.Buffers;
|
|
|
|
namespace MemoryPools.Collections.Specialized
|
|
{
|
|
internal abstract class PoolingNodeBase<T> : IPoolingNode<T>
|
|
{
|
|
protected IMemoryOwner<T> _buf;
|
|
|
|
public int Length => _buf.Memory.Length;
|
|
|
|
public virtual T this[int index]
|
|
{
|
|
get => _buf.Memory.Span[index];
|
|
set => _buf.Memory.Span[index] = value;
|
|
}
|
|
|
|
public virtual void Dispose()
|
|
{
|
|
_buf.Dispose();
|
|
_buf = null!;
|
|
Next = null!;
|
|
}
|
|
|
|
public IPoolingNode<T> Next { get; set; }
|
|
|
|
public abstract IPoolingNode<T> Init(int capacity);
|
|
|
|
public void Clear()
|
|
{
|
|
_buf.Memory.Span.Clear();
|
|
}
|
|
}
|
|
} |