Several hints removed & code cleaned up.
This commit is contained in:
1 parent
b038bcfdc9
commit
dfb671aff7
26 files changed
+106
-138
No files matched your search
@@ -63,6 +63,5 @@ namespace Recyclable.Collections.Benchmarks
|
||||
DoNothing(list.Contains(data[^(i + 1)]));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
|
||||
if (nextItemBlockIndex == data.LastBlockWithData)
|
||||
{
|
||||
|
||||
var memoryBlock = new Span<long>(memoryBlocks[nextItemBlockIndex], 0, data.NextItemIndex);
|
||||
for (var itemIndex = 0; itemIndex < memoryBlock.Length; itemIndex++)
|
||||
{
|
||||
@@ -119,8 +118,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
public void RecyclableList_GetItem_AsForEach()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableList;
|
||||
var dataCount = TestObjectCount;
|
||||
|
||||
foreach (var item in data)
|
||||
{
|
||||
DoNothing(item);
|
||||
|
||||
@@ -75,6 +75,5 @@ namespace Recyclable.Collections.Benchmarks
|
||||
DoNothing(list.LongIndexOf(data[i]));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -75,6 +75,5 @@ namespace Recyclable.Collections.Benchmarks
|
||||
DoNothing(list.LongIndexOf(data[i]));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -75,6 +75,5 @@ namespace Recyclable.Collections.Benchmarks
|
||||
DoNothing(list.LongIndexOf(data[^(i + 1)]));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,5 @@ namespace Recyclable.Collections.Benchmarks
|
||||
var data = TestObjectsAsRecyclableList;
|
||||
DoNothing(data.LongCount);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,5 @@ namespace Recyclable.Collections.Benchmarks
|
||||
DoNothing(list.Remove(data[i]));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Collections.Pooled;
|
||||
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Recyclable.Collections.Benchmarks.Core
|
||||
{
|
||||
public class DataGenerator
|
||||
public static class DataGenerator
|
||||
{
|
||||
public static long[] EnumerateTestObjects(long testObjectCount)
|
||||
{
|
||||
@@ -15,6 +15,5 @@ namespace Recyclable.Collections.Benchmarks.Core
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,14 +12,14 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
benchmark.Bool();
|
||||
benchmark.Compare();
|
||||
}
|
||||
|
||||
|
||||
private static void DoNothing<T>(T result, [CallerMemberName] string? callerName = null)
|
||||
{
|
||||
//Console.WriteLine($"{callerName}: result = {result}");
|
||||
}
|
||||
|
||||
private bool _testBool = true;
|
||||
private int _blockSize = 8;
|
||||
private readonly bool _testBool = true;
|
||||
private readonly int _blockSize = 8;
|
||||
|
||||
[Benchmark(Baseline = false)]
|
||||
public void Bool()
|
||||
|
||||
@@ -64,13 +64,13 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
private const int _objectCount = 1_000_000;
|
||||
private static readonly IEnumerable<long> _testObjects = Enumerable.Range(1, _objectCount).Select(x => (long)x);
|
||||
private static readonly IEnumerable<Func<long, long, int>> _testListOfFunctions = _testObjects.Select<long, Func<long, long, int>>(static x => new MyComparer().Compare);
|
||||
private static readonly IEnumerable<IComparer<long>> _testListOfComparers = _testObjects.Select(x => (IComparer<long>)new MyComparer());
|
||||
private static readonly IEnumerable<Compare<long>> _testListOfDelegates = _testObjects.Select(x => new Compare<long>((x, y) => new MyComparer().Compare(x, y)));
|
||||
private static readonly IEnumerable<Func<long, long, int>> _testListOfFunctions = _testObjects.Select<long, Func<long, long, int>>(static _ => new MyComparer().Compare);
|
||||
private static readonly IEnumerable<IComparer<long>> _testListOfComparers = _testObjects.Select(_ => (IComparer<long>)new MyComparer());
|
||||
private static readonly IEnumerable<Compare<long>> _testListOfDelegates = _testObjects.Select(_ => new Compare<long>((x, y) => new MyComparer().Compare(x, y)));
|
||||
private static readonly IEnumerable<Func<long, long, int>> _testListOfLocalFunctions = GetLocalFunctions(_testObjects);
|
||||
private static readonly IEnumerable<MyComparer> _testListOfClasses = _testObjects.Select(x => new MyComparer());
|
||||
private static readonly IEnumerable<MyComparerStruct<long>> _testListOfStructs = _testObjects.Select(x => new MyComparerStruct<long>());
|
||||
private static readonly IEnumerable<IComparer<long>> _testListOfBoxedStructs = _testObjects.Select(x => (IComparer<long>)new MyComparerStruct<long>());
|
||||
private static readonly IEnumerable<MyComparer> _testListOfClasses = _testObjects.Select(_ => new MyComparer());
|
||||
private static readonly IEnumerable<MyComparerStruct<long>> _testListOfStructs = _testObjects.Select(_ => new MyComparerStruct<long>());
|
||||
private static readonly IEnumerable<IComparer<long>> _testListOfBoxedStructs = _testObjects.Select(_ => (IComparer<long>)new MyComparerStruct<long>());
|
||||
private static IEnumerable<TComparer> _testListOfUnboxedStructs<TComparer, TValue>() where TComparer : IComparer<TValue>, new()
|
||||
{
|
||||
foreach (var item in _testObjects)
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
benchmark.XDivYMulX();
|
||||
benchmark.XDivYMulXWithLocalVar();
|
||||
}
|
||||
|
||||
|
||||
private long _cutoff;
|
||||
private Vector128<long> _increment;
|
||||
private long _lastCaseIndex;
|
||||
|
||||
+9
-11
@@ -586,7 +586,6 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
{
|
||||
_nextItemIndex = (int)(targetCapacity & (blockSize - 1));
|
||||
_nextItemBlockIndex = targetBlockIndex;
|
||||
|
||||
}
|
||||
|
||||
_longCount = targetCapacity;
|
||||
@@ -872,7 +871,6 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region RecyclableList v2
|
||||
@@ -1117,10 +1115,11 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
/// <param name="minBlockSize">Minimal requested block size. It MUST be rounded to the power of 2, see remarks.</param>
|
||||
/// <param name="minBlockSizeBitShift">Pre-calculated bit shifting value for left & right shift operations against<paramref name="minBlockSize"/>.</param>
|
||||
/// <param name="newCapacity">The minimum no. of items <paramref name="list"/> MUST be able to store after <see cref="RecyclableListV2{T}.Resize(RecyclableListV2{T}, int, byte, long)"/>.</param>
|
||||
/// <remarks>For performance reasons, <paramref name="minBlockSize"/> MUST a power of 2. This simplifies a lot block & item
|
||||
/// <remarks><para>
|
||||
/// For performance reasons, <paramref name="minBlockSize"/> MUST a power of 2. This simplifies a lot block & item
|
||||
/// index calculations, i.e. makes them logical operations on bits.
|
||||
///
|
||||
/// This method checks for integral overflow.
|
||||
/// </para>
|
||||
/// <para>This method checks for integral overflow.</para>
|
||||
/// </remarks>
|
||||
/// <returns>The maximum no. of items <paramref name="list"/> can store.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
@@ -1485,7 +1484,6 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
{
|
||||
_nextItemIndex = checked((int)(targetCapacity & (blockSize - 1)));
|
||||
_nextItemBlockIndex = targetBlockIndex;
|
||||
|
||||
}
|
||||
|
||||
_longCount = targetCapacity;
|
||||
@@ -2089,10 +2087,11 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
/// <param name="minBlockSize">Minimal requested block size. It MUST be rounded to the power of 2, see remarks.</param>
|
||||
/// <param name="minBlockSizePow2Shift">Pre-calculated bit shifting value for left & right shift operations against<paramref name="minBlockSize"/>.</param>
|
||||
/// <param name="newCapacity">The minimum no. of items <paramref name="list"/> MUST be able to store after <see cref="RecyclableList{T}.Resize(RecyclableList{T}, int, byte, long)"/>.</param>
|
||||
/// <remarks>For performance reasons, <paramref name="minBlockSize"/> MUST a power of 2. This simplifies a lot block & item
|
||||
/// <remarks><para>
|
||||
/// For performance reasons, <paramref name="minBlockSize"/> MUST a power of 2. This simplifies a lot block & item
|
||||
/// index calculations, i.e. makes them logical operations on bits.
|
||||
///
|
||||
/// This method checks for integral overflow.
|
||||
/// </para>
|
||||
/// <para>This method checks for integral overflow.</para>
|
||||
/// </remarks>
|
||||
/// <returns>The maximum no. of items <paramref name="list"/> can store.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
@@ -2446,7 +2445,6 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
{
|
||||
_nextItemIndex = checked((int)(targetCapacity & _blockSizeMinus1));
|
||||
_nextItemBlockIndex = targetBlockIndex;
|
||||
|
||||
}
|
||||
|
||||
_longCount = targetCapacity;
|
||||
@@ -2804,7 +2802,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
public partial class RecyclableListPocBenchmarks
|
||||
|
||||
@@ -404,10 +404,11 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
/// <param name="minBlockSize">Minimal requested block size. It MUST be rounded to the power of 2, see remarks.</param>
|
||||
/// <param name="minBlockSizePow2Shift">Pre-calculated bit shifting value for left & right shift operations against<paramref name="minBlockSize"/>.</param>
|
||||
/// <param name="newCapacity">The minimum no. of items <paramref name="list"/> MUST be able to store after <see cref="RecyclableList{T}.Resize(RecyclableList{T}, int, byte, long)"/>.</param>
|
||||
/// <remarks>For performance reasons, <paramref name="minBlockSize"/> MUST a power of 2. This simplifies a lot block & item
|
||||
/// <remarks><para>
|
||||
/// For performance reasons, <paramref name="minBlockSize"/> MUST a power of 2. This simplifies a lot block & item
|
||||
/// index calculations, i.e. makes them logical operations on bits.
|
||||
///
|
||||
/// This method checks for integral overflow.
|
||||
/// </para>
|
||||
/// <para>This method checks for integral overflow.</para>
|
||||
/// </remarks>
|
||||
/// <remarks>
|
||||
/// This method doesn't support downsizing the memory block. As such it doesn't release excessive blocks. This is to for additional performance
|
||||
@@ -457,7 +458,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
blockIndex = sourceBlockCount;
|
||||
do
|
||||
while (true)
|
||||
{
|
||||
newMemoryBlocks[blockIndex] = blockArrayPool.Rent(minBlockSize);
|
||||
if (blockIndex + 1 < requiredBlockCount)
|
||||
@@ -468,24 +469,24 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
{
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
blockIndex = sourceBlockCount;
|
||||
do
|
||||
{
|
||||
newMemoryBlocks[blockIndex] = new T[minBlockSize];
|
||||
if (blockIndex + 1 < requiredBlockCount)
|
||||
{
|
||||
blockIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
while (true)
|
||||
{
|
||||
newMemoryBlocks[blockIndex] = new T[minBlockSize];
|
||||
if (blockIndex + 1 < requiredBlockCount)
|
||||
{
|
||||
blockIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list._reservedBlockCount = requiredBlockCount;
|
||||
@@ -773,7 +774,6 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
{
|
||||
_nextItemIndex = checked((int)(targetCapacity & _blockSizeMinus1));
|
||||
_nextItemBlockIndex = targetBlockIndex;
|
||||
|
||||
}
|
||||
|
||||
_longCount = targetCapacity;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
benchmark.RefToInt2();
|
||||
benchmark.RefToInt3();
|
||||
}
|
||||
|
||||
|
||||
private readonly TestCase _testCase = new();
|
||||
private static void DoNothing(int count)
|
||||
{
|
||||
|
||||
@@ -22,12 +22,11 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
//[Params(329_000, 512_000, 750_000, 1_000_000, 3_290_000)]
|
||||
//public int Step { get; set; } = 329_000; // This was the fastest so far
|
||||
|
||||
private static readonly int _numberOfProcessors = Environment.ProcessorCount;
|
||||
private RecyclableList<long>? _testData;
|
||||
|
||||
public object? ItemToFind { get; set; }
|
||||
|
||||
[GlobalSetup]
|
||||
[GlobalSetup]
|
||||
public void Setup()
|
||||
{
|
||||
_testData = Enumerable.Range(1, TestObjectCount).Cast<long>().ToRecyclableList(BlockSize);
|
||||
@@ -40,7 +39,6 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
_testData = default;
|
||||
}
|
||||
|
||||
|
||||
[Benchmark(Baseline = true)]
|
||||
public void IndexOfSequentially()
|
||||
{
|
||||
@@ -262,7 +260,6 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// if (threadIndex + 1 < numberOfRanges && blockIndex <= _testData.LastBlockWithData)
|
||||
// {
|
||||
// threadIndex++;
|
||||
|
||||
@@ -5,13 +5,13 @@ namespace Recyclable.Collections
|
||||
{
|
||||
public static class MathUtils
|
||||
{
|
||||
private static readonly long[] Pow2 = new long[]
|
||||
{
|
||||
1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384,
|
||||
32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304,
|
||||
8388608, 16777216, 33554432, 67108864, 134217728, 268435456,
|
||||
536870912, 1073741824, 2147483648
|
||||
};
|
||||
// private static readonly long[] Pow2 = new long[]
|
||||
// {
|
||||
// 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384,
|
||||
// 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304,
|
||||
// 8388608, 16777216, 33554432, 67108864, 134217728, 268435456,
|
||||
// 536870912, 1073741824, 2147483648
|
||||
// };
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool IsPow2(long value) => (value != 0) && ((value & (value - 1)) == 0);
|
||||
|
||||
@@ -8,7 +8,6 @@ namespace Recyclable.Collections
|
||||
{
|
||||
private const int ItemNotFound = -1;
|
||||
private static readonly ArrayPool<T> _arrayPool = ArrayPool<T>.Create();
|
||||
private static readonly IEqualityComparer<T> _equalityComparer = EqualityComparer<T>.Default;
|
||||
|
||||
protected static readonly bool NeedsClearing = !typeof(T).IsValueType;
|
||||
|
||||
@@ -129,7 +128,7 @@ namespace Recyclable.Collections
|
||||
}
|
||||
|
||||
protected int _capacity;
|
||||
public int Capacity
|
||||
public int Capacity
|
||||
{
|
||||
get => _capacity;
|
||||
set
|
||||
@@ -340,30 +339,26 @@ namespace Recyclable.Collections
|
||||
if (enumerator.MoveNext())
|
||||
{
|
||||
int available = capacity - targetItemIdx;
|
||||
while (true)
|
||||
{
|
||||
if (targetItemIdx + growByCount > capacity)
|
||||
{
|
||||
do
|
||||
{
|
||||
if (targetItemIdx + growByCount > capacity)
|
||||
{
|
||||
capacity = EnsureCapacity(capacity + growByCount);
|
||||
memorySpan = new(_memoryBlock);
|
||||
available = capacity - targetItemIdx;
|
||||
}
|
||||
memorySpan = new(_memoryBlock);
|
||||
available = capacity - targetItemIdx;
|
||||
}
|
||||
|
||||
for (i = 0; i < available; i++)
|
||||
{
|
||||
memorySpan[targetItemIdx++] = enumerator.Current;
|
||||
if (!enumerator.MoveNext())
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i < available)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (i = 0; i < available; i++)
|
||||
{
|
||||
memorySpan[targetItemIdx++] = enumerator.Current;
|
||||
if (!enumerator.MoveNext())
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (i >= available);
|
||||
}
|
||||
|
||||
_count = targetItemIdx;
|
||||
}
|
||||
@@ -459,6 +454,7 @@ namespace Recyclable.Collections
|
||||
}
|
||||
|
||||
public IEnumerator<T> GetEnumerator() => Enumerate(this).GetEnumerator();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => Enumerate(this).GetEnumerator();
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -373,10 +373,11 @@ namespace Recyclable.Collections
|
||||
/// <param name="minBlockSize">Minimal requested block size. It MUST be rounded to the power of 2, see remarks.</param>
|
||||
/// <param name="minBlockSizePow2Shift">Pre-calculated bit shifting value for left & right shift operations against<paramref name="minBlockSize"/>.</param>
|
||||
/// <param name="newCapacity">The minimum no. of items <paramref name="list"/> MUST be able to store after <see cref="RecyclableList{T}.Resize(RecyclableList{T}, int, byte, long)"/>.</param>
|
||||
/// <remarks>For performance reasons, <paramref name="minBlockSize"/> MUST a power of 2. This simplifies a lot block & item
|
||||
/// <remarks><para>
|
||||
/// For performance reasons, <paramref name="minBlockSize"/> MUST a power of 2. This simplifies a lot block & item
|
||||
/// index calculations, i.e. makes them logical operations on bits.
|
||||
///
|
||||
/// This method checks for integral overflow.
|
||||
/// </para>
|
||||
/// <para>This method checks for integral overflow.</para>
|
||||
/// </remarks>
|
||||
/// <remarks>
|
||||
/// This method doesn't support downsizing the memory block. As such it doesn't release excessive blocks. This is to for additional performance
|
||||
@@ -426,35 +427,35 @@ namespace Recyclable.Collections
|
||||
}
|
||||
|
||||
blockIndex = sourceBlockCount;
|
||||
do
|
||||
{
|
||||
newMemoryBlocks[blockIndex] = blockArrayPool.Rent(minBlockSize);
|
||||
if (blockIndex + 1 < requiredBlockCount)
|
||||
{
|
||||
blockIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
while (true)
|
||||
{
|
||||
newMemoryBlocks[blockIndex] = blockArrayPool.Rent(minBlockSize);
|
||||
if (blockIndex + 1 < requiredBlockCount)
|
||||
{
|
||||
blockIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
blockIndex = sourceBlockCount;
|
||||
do
|
||||
{
|
||||
newMemoryBlocks[blockIndex] = new T[minBlockSize];
|
||||
if (blockIndex + 1 < requiredBlockCount)
|
||||
{
|
||||
blockIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
while (true)
|
||||
{
|
||||
newMemoryBlocks[blockIndex] = new T[minBlockSize];
|
||||
if (blockIndex + 1 < requiredBlockCount)
|
||||
{
|
||||
blockIndex++;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list._reservedBlockCount = requiredBlockCount;
|
||||
@@ -742,7 +743,6 @@ namespace Recyclable.Collections
|
||||
{
|
||||
_nextItemIndex = checked((int)(targetCapacity & _blockSizeMinus1));
|
||||
_nextItemBlockIndex = targetBlockIndex;
|
||||
|
||||
}
|
||||
|
||||
_longCount = targetCapacity;
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace Recyclable.Collections
|
||||
return scannedCount;
|
||||
}
|
||||
|
||||
scannedCount++;
|
||||
scannedCount++;
|
||||
if (scannedCount == itemsCount)
|
||||
{
|
||||
return -1;
|
||||
|
||||
@@ -193,19 +193,14 @@ namespace Recyclable.Collections
|
||||
}
|
||||
}
|
||||
|
||||
protected void Dispose(bool disposing)
|
||||
public void Dispose()
|
||||
{
|
||||
if (!_disposedValue)
|
||||
{
|
||||
Clear();
|
||||
_disposedValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||
Dispose(disposing: true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
QuickSort();
|
||||
}
|
||||
|
||||
public RecyclableSortedList(int blockSize = RecyclableDefaults.BlockSize)
|
||||
public RecyclableSortedList(int blockSize = RecyclableDefaults.BlockSize)
|
||||
: base(blockSize)
|
||||
{
|
||||
}
|
||||
@@ -73,7 +73,7 @@
|
||||
finally
|
||||
{
|
||||
EndUpdate(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace Recyclable.CollectionsTests
|
||||
{
|
||||
public class EnumerableWithoutCount<T> : IEnumerable<T>
|
||||
{
|
||||
private IEnumerable<T> _testData;
|
||||
private readonly IEnumerable<T> _testData;
|
||||
|
||||
public EnumerableWithoutCount(IEnumerable<T> testData)
|
||||
{
|
||||
|
||||
@@ -127,7 +127,6 @@ namespace Recyclable.CollectionsTests
|
||||
(9, 0, 1),
|
||||
}
|
||||
},
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -217,7 +217,6 @@ namespace Recyclable.CollectionsTests
|
||||
// Validate
|
||||
_ = list.Count.Should().Be(0);
|
||||
_ = list.Should().BeEmpty();
|
||||
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -350,10 +349,7 @@ namespace Recyclable.CollectionsTests
|
||||
|
||||
// Act
|
||||
var yieldedItems = new List<long>((int)itemsCount);
|
||||
foreach (var item in list)
|
||||
{
|
||||
yieldedItems.Add(item);
|
||||
}
|
||||
yieldedItems.AddRange(list);
|
||||
|
||||
// Validate
|
||||
_ = yieldedItems.Count.Should().Be((int)itemsCount);
|
||||
@@ -549,8 +545,7 @@ namespace Recyclable.CollectionsTests
|
||||
// Validate
|
||||
_ = list.Count.Should().Be((int)(itemsCount - deleted));
|
||||
_ = list.Should().ContainInConsecutiveOrder(testData.Take((int)(itemsCount - deleted)));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,6 @@ namespace Recyclable.CollectionsTests
|
||||
CreateTestData(itemsCount).ToRecyclableList(sourceBlockSize),
|
||||
itemsCount
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
yield return new object[] { $"IList<int>(itemsCount: {itemsCount})", new CustomIList<long>(CreateTestData(itemsCount)), itemsCount };
|
||||
@@ -64,7 +63,7 @@ namespace Recyclable.CollectionsTests
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> SourceDataVariants => CreateSourceDataVariants().ToArray();
|
||||
|
||||
|
||||
private static IEnumerable<object[]> CreateSourceEmptyDataVariants() => new[]
|
||||
{
|
||||
new object[] { "int[]", Array.Empty<long>() },
|
||||
|
||||
Reference in new issue
Block a user