using System.Buffers; namespace MemoryPools.Collections.Specialized { internal abstract class PoolingNodeBase : IPoolingNode { protected IMemoryOwner _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 Next { get; set; } public abstract IPoolingNode Init(int capacity); public void Clear() { _buf.Memory.Span.Clear(); } } }