RecyclableList<T> marked as sealed. All protected entities made private. Future versions will provide a way to create your own, top performance collections.
This commit is contained in:
1 parent
c3820a61d9
commit
f66b129f3a
2 files changed
+13
-13
No files matched your search
@@ -9,21 +9,21 @@ namespace Recyclable.Collections
|
|||||||
{
|
{
|
||||||
private static readonly ArrayPool<T> _arrayPool = ArrayPool<T>.Create();
|
private static readonly ArrayPool<T> _arrayPool = ArrayPool<T>.Create();
|
||||||
private static readonly bool _defaultIsNull = default(T) == null;
|
private static readonly bool _defaultIsNull = default(T) == null;
|
||||||
protected static readonly bool NeedsClearing = !typeof(T).IsValueType;
|
private static readonly bool NeedsClearing = !typeof(T).IsValueType;
|
||||||
|
|
||||||
public static explicit operator ReadOnlySpan<T>(RecyclableList<T> source) => new(source._memoryBlock, 0, source.Count);
|
public static explicit operator ReadOnlySpan<T>(RecyclableList<T> source) => new(source._memoryBlock, 0, source.Count);
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
protected T[] _memoryBlock;
|
private T[] _memoryBlock;
|
||||||
#nullable restore
|
#nullable restore
|
||||||
// & WAS SLOWER
|
// & WAS SLOWER
|
||||||
// internal RecyclableCollectionVersion _version;
|
// internal RecyclableCollectionVersion _version;
|
||||||
// public RecyclableCollectionVersion Version => _version;
|
// public RecyclableCollectionVersion Version => _version;
|
||||||
|
|
||||||
protected ulong _version;
|
private ulong _version;
|
||||||
public ulong Version => _version;
|
public ulong Version => _version;
|
||||||
|
|
||||||
protected IEnumerator<T> AddRangeEnumerated(IEnumerable<T> source, int growByCount)
|
private IEnumerator<T> AddRangeEnumerated(IEnumerable<T> source, int growByCount)
|
||||||
{
|
{
|
||||||
int targetItemIdx = _count;
|
int targetItemIdx = _count;
|
||||||
Span<T> memorySpan;
|
Span<T> memorySpan;
|
||||||
@@ -61,7 +61,7 @@ namespace Recyclable.Collections
|
|||||||
return enumerator;
|
return enumerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void AddRangeWithKnownCount(IEnumerable<T> source, int targetItemIdx, int requiredAdditionalCapacity)
|
private void AddRangeWithKnownCount(IEnumerable<T> source, int targetItemIdx, int requiredAdditionalCapacity)
|
||||||
{
|
{
|
||||||
_ = EnsureCapacity(this, targetItemIdx + requiredAdditionalCapacity);
|
_ = EnsureCapacity(this, targetItemIdx + requiredAdditionalCapacity);
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ namespace Recyclable.Collections
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
protected static T[] Resize(in T[]? source, int newSize)
|
private static T[] Resize(in T[]? source, int newSize)
|
||||||
{
|
{
|
||||||
ArrayPool<T> arrayPool = _arrayPool;
|
ArrayPool<T> arrayPool = _arrayPool;
|
||||||
T[] newMemoryBlock = newSize >= RecyclableDefaults.MinPooledArrayLength
|
T[] newMemoryBlock = newSize >= RecyclableDefaults.MinPooledArrayLength
|
||||||
@@ -100,7 +100,7 @@ namespace Recyclable.Collections
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
protected static int EnsureCapacity(RecyclableList<T> list, int requestedCapacity)
|
private static int EnsureCapacity(RecyclableList<T> list, int requestedCapacity)
|
||||||
{
|
{
|
||||||
int newCapacity;
|
int newCapacity;
|
||||||
switch (list._capacity > 0)
|
switch (list._capacity > 0)
|
||||||
@@ -204,7 +204,7 @@ namespace Recyclable.Collections
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int _capacity;
|
private int _capacity;
|
||||||
public int Capacity
|
public int Capacity
|
||||||
{
|
{
|
||||||
get => _capacity;
|
get => _capacity;
|
||||||
@@ -219,7 +219,7 @@ namespace Recyclable.Collections
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int _count;
|
private int _count;
|
||||||
public int Count => _count;
|
public int Count => _count;
|
||||||
//{
|
//{
|
||||||
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using System.Runtime.CompilerServices;
|
|||||||
|
|
||||||
namespace Recyclable.Collections
|
namespace Recyclable.Collections
|
||||||
{
|
{
|
||||||
public partial class RecyclableLongList<T> : IList<T>, IReadOnlyList<T>, IDisposable
|
public partial sealed class RecyclableLongList<T> : IList<T>, IReadOnlyList<T>, IDisposable
|
||||||
{
|
{
|
||||||
private static readonly ArrayPool<T[]> _defaultMemoryBlocksPool = ArrayPool<T[]>.Create();
|
private static readonly ArrayPool<T[]> _defaultMemoryBlocksPool = ArrayPool<T[]>.Create();
|
||||||
private static readonly ArrayPool<T> _defaultBlockArrayPool = ArrayPool<T>.Create();
|
private static readonly ArrayPool<T> _defaultBlockArrayPool = ArrayPool<T>.Create();
|
||||||
@@ -25,10 +25,10 @@ namespace Recyclable.Collections
|
|||||||
internal int _nextItemIndex;
|
internal int _nextItemIndex;
|
||||||
private int _reservedBlockCount;
|
private int _reservedBlockCount;
|
||||||
|
|
||||||
protected static readonly bool NeedsClearing = !typeof(T).IsValueType;
|
private static readonly bool NeedsClearing = !typeof(T).IsValueType;
|
||||||
|
|
||||||
protected ArrayPool<T[]> _memoryBlocksPool;
|
private ArrayPool<T[]> _memoryBlocksPool;
|
||||||
protected ArrayPool<T> _blockArrayPool;
|
private ArrayPool<T> _blockArrayPool;
|
||||||
#nullable disable
|
#nullable disable
|
||||||
internal T[][] _memoryBlocks;
|
internal T[][] _memoryBlocks;
|
||||||
#nullable restore
|
#nullable restore
|
||||||
|
|||||||
Reference in new issue
Block a user