diff --git a/Recyclable.Collections.Benchmarks/Benchmarks/Contains_LastItems.cs b/Recyclable.Collections.Benchmarks/Benchmarks/Contains_LastItems.cs index dc9da22..d0b50c9 100644 --- a/Recyclable.Collections.Benchmarks/Benchmarks/Contains_LastItems.cs +++ b/Recyclable.Collections.Benchmarks/Benchmarks/Contains_LastItems.cs @@ -63,6 +63,5 @@ namespace Recyclable.Collections.Benchmarks DoNothing(list.Contains(data[^(i + 1)])); } } - } } diff --git a/Recyclable.Collections.Benchmarks/Benchmarks/GetItem..cs b/Recyclable.Collections.Benchmarks/Benchmarks/GetItem..cs index 27006d4..374abbd 100644 --- a/Recyclable.Collections.Benchmarks/Benchmarks/GetItem..cs +++ b/Recyclable.Collections.Benchmarks/Benchmarks/GetItem..cs @@ -78,7 +78,6 @@ namespace Recyclable.Collections.Benchmarks if (nextItemBlockIndex == data.LastBlockWithData) { - var memoryBlock = new Span(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); diff --git a/Recyclable.Collections.Benchmarks/Benchmarks/IndexOf_AllItems.cs b/Recyclable.Collections.Benchmarks/Benchmarks/IndexOf_AllItems.cs index eff6950..1df873c 100644 --- a/Recyclable.Collections.Benchmarks/Benchmarks/IndexOf_AllItems.cs +++ b/Recyclable.Collections.Benchmarks/Benchmarks/IndexOf_AllItems.cs @@ -75,6 +75,5 @@ namespace Recyclable.Collections.Benchmarks DoNothing(list.LongIndexOf(data[i])); } } - } } diff --git a/Recyclable.Collections.Benchmarks/Benchmarks/IndexOf_FirstItems.cs b/Recyclable.Collections.Benchmarks/Benchmarks/IndexOf_FirstItems.cs index 412f4d6..a7bbe76 100644 --- a/Recyclable.Collections.Benchmarks/Benchmarks/IndexOf_FirstItems.cs +++ b/Recyclable.Collections.Benchmarks/Benchmarks/IndexOf_FirstItems.cs @@ -75,6 +75,5 @@ namespace Recyclable.Collections.Benchmarks DoNothing(list.LongIndexOf(data[i])); } } - } } diff --git a/Recyclable.Collections.Benchmarks/Benchmarks/IndexOf_LastItems.cs b/Recyclable.Collections.Benchmarks/Benchmarks/IndexOf_LastItems.cs index f12a329..22910c4 100644 --- a/Recyclable.Collections.Benchmarks/Benchmarks/IndexOf_LastItems.cs +++ b/Recyclable.Collections.Benchmarks/Benchmarks/IndexOf_LastItems.cs @@ -75,6 +75,5 @@ namespace Recyclable.Collections.Benchmarks DoNothing(list.LongIndexOf(data[^(i + 1)])); } } - } } diff --git a/Recyclable.Collections.Benchmarks/Benchmarks/LongCount.cs b/Recyclable.Collections.Benchmarks/Benchmarks/LongCount.cs index e299491..426cf3e 100644 --- a/Recyclable.Collections.Benchmarks/Benchmarks/LongCount.cs +++ b/Recyclable.Collections.Benchmarks/Benchmarks/LongCount.cs @@ -17,6 +17,5 @@ namespace Recyclable.Collections.Benchmarks var data = TestObjectsAsRecyclableList; DoNothing(data.LongCount); } - } } diff --git a/Recyclable.Collections.Benchmarks/Benchmarks/Remove_FirstItems.cs b/Recyclable.Collections.Benchmarks/Benchmarks/Remove_FirstItems.cs index e53045a..c0e77b0 100644 --- a/Recyclable.Collections.Benchmarks/Benchmarks/Remove_FirstItems.cs +++ b/Recyclable.Collections.Benchmarks/Benchmarks/Remove_FirstItems.cs @@ -52,6 +52,5 @@ namespace Recyclable.Collections.Benchmarks DoNothing(list.Remove(data[i])); } } - } } diff --git a/Recyclable.Collections.Benchmarks/Benchmarks/Remove_LastItems.cs b/Recyclable.Collections.Benchmarks/Benchmarks/Remove_LastItems.cs index 571d56a..aeb7207 100644 --- a/Recyclable.Collections.Benchmarks/Benchmarks/Remove_LastItems.cs +++ b/Recyclable.Collections.Benchmarks/Benchmarks/Remove_LastItems.cs @@ -1,7 +1,6 @@ using BenchmarkDotNet.Attributes; using Collections.Pooled; - namespace Recyclable.Collections.Benchmarks { public partial class RecyclableCollectionsBenchmarks diff --git a/Recyclable.Collections.Benchmarks/Core/DataGenerator.cs b/Recyclable.Collections.Benchmarks/Core/DataGenerator.cs index b4d8321..faaaf4e 100644 --- a/Recyclable.Collections.Benchmarks/Core/DataGenerator.cs +++ b/Recyclable.Collections.Benchmarks/Core/DataGenerator.cs @@ -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; } - } } \ No newline at end of file diff --git a/Recyclable.Collections.Benchmarks/POC/BoolOrComparePoc.Benchmarks.cs b/Recyclable.Collections.Benchmarks/POC/BoolOrComparePoc.Benchmarks.cs index 61b0c8d..51e002c 100644 --- a/Recyclable.Collections.Benchmarks/POC/BoolOrComparePoc.Benchmarks.cs +++ b/Recyclable.Collections.Benchmarks/POC/BoolOrComparePoc.Benchmarks.cs @@ -12,14 +12,14 @@ namespace Recyclable.Collections.Benchmarks.POC benchmark.Bool(); benchmark.Compare(); } - + private static void DoNothing(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() diff --git a/Recyclable.Collections.Benchmarks/POC/DelegateVsComparerPoc.Benchmarks.cs b/Recyclable.Collections.Benchmarks/POC/DelegateVsComparerPoc.Benchmarks.cs index 4cd9e75..5b7e462 100644 --- a/Recyclable.Collections.Benchmarks/POC/DelegateVsComparerPoc.Benchmarks.cs +++ b/Recyclable.Collections.Benchmarks/POC/DelegateVsComparerPoc.Benchmarks.cs @@ -64,13 +64,13 @@ namespace Recyclable.Collections.Benchmarks.POC private const int _objectCount = 1_000_000; private static readonly IEnumerable _testObjects = Enumerable.Range(1, _objectCount).Select(x => (long)x); - private static readonly IEnumerable> _testListOfFunctions = _testObjects.Select>(static x => new MyComparer().Compare); - private static readonly IEnumerable> _testListOfComparers = _testObjects.Select(x => (IComparer)new MyComparer()); - private static readonly IEnumerable> _testListOfDelegates = _testObjects.Select(x => new Compare((x, y) => new MyComparer().Compare(x, y))); + private static readonly IEnumerable> _testListOfFunctions = _testObjects.Select>(static _ => new MyComparer().Compare); + private static readonly IEnumerable> _testListOfComparers = _testObjects.Select(_ => (IComparer)new MyComparer()); + private static readonly IEnumerable> _testListOfDelegates = _testObjects.Select(_ => new Compare((x, y) => new MyComparer().Compare(x, y))); private static readonly IEnumerable> _testListOfLocalFunctions = GetLocalFunctions(_testObjects); - private static readonly IEnumerable _testListOfClasses = _testObjects.Select(x => new MyComparer()); - private static readonly IEnumerable> _testListOfStructs = _testObjects.Select(x => new MyComparerStruct()); - private static readonly IEnumerable> _testListOfBoxedStructs = _testObjects.Select(x => (IComparer)new MyComparerStruct()); + private static readonly IEnumerable _testListOfClasses = _testObjects.Select(_ => new MyComparer()); + private static readonly IEnumerable> _testListOfStructs = _testObjects.Select(_ => new MyComparerStruct()); + private static readonly IEnumerable> _testListOfBoxedStructs = _testObjects.Select(_ => (IComparer)new MyComparerStruct()); private static IEnumerable _testListOfUnboxedStructs() where TComparer : IComparer, new() { foreach (var item in _testObjects) diff --git a/Recyclable.Collections.Benchmarks/POC/ModuloPoc.Benchmarks.cs b/Recyclable.Collections.Benchmarks/POC/ModuloPoc.Benchmarks.cs index d5f4ddb..2fb2154 100644 --- a/Recyclable.Collections.Benchmarks/POC/ModuloPoc.Benchmarks.cs +++ b/Recyclable.Collections.Benchmarks/POC/ModuloPoc.Benchmarks.cs @@ -27,7 +27,7 @@ namespace Recyclable.Collections.Benchmarks.POC benchmark.XDivYMulX(); benchmark.XDivYMulXWithLocalVar(); } - + private long _cutoff; private Vector128 _increment; private long _lastCaseIndex; diff --git a/Recyclable.Collections.Benchmarks/POC/RecyclableListPoc.Benchmarks.EnsureCapacity.cs b/Recyclable.Collections.Benchmarks/POC/RecyclableListPoc.Benchmarks.EnsureCapacity.cs index da5f07c..182aa61 100644 --- a/Recyclable.Collections.Benchmarks/POC/RecyclableListPoc.Benchmarks.EnsureCapacity.cs +++ b/Recyclable.Collections.Benchmarks/POC/RecyclableListPoc.Benchmarks.EnsureCapacity.cs @@ -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 /// Minimal requested block size. It MUST be rounded to the power of 2, see remarks. /// Pre-calculated bit shifting value for left & right shift operations against. /// The minimum no. of items MUST be able to store after . - /// For performance reasons, MUST a power of 2. This simplifies a lot block & item + /// + /// For performance reasons, 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. + /// + /// This method checks for integral overflow. /// /// The maximum no. of items can store. [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 /// Minimal requested block size. It MUST be rounded to the power of 2, see remarks. /// Pre-calculated bit shifting value for left & right shift operations against. /// The minimum no. of items MUST be able to store after . - /// For performance reasons, MUST a power of 2. This simplifies a lot block & item + /// + /// For performance reasons, 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. + /// + /// This method checks for integral overflow. /// /// The maximum no. of items can store. [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 diff --git a/Recyclable.Collections.Benchmarks/POC/RecyclableListPoc.Benchmarks.IndexOf.cs b/Recyclable.Collections.Benchmarks/POC/RecyclableListPoc.Benchmarks.IndexOf.cs index 3ae38da..5f89df1 100644 --- a/Recyclable.Collections.Benchmarks/POC/RecyclableListPoc.Benchmarks.IndexOf.cs +++ b/Recyclable.Collections.Benchmarks/POC/RecyclableListPoc.Benchmarks.IndexOf.cs @@ -404,10 +404,11 @@ namespace Recyclable.Collections.Benchmarks.POC /// Minimal requested block size. It MUST be rounded to the power of 2, see remarks. /// Pre-calculated bit shifting value for left & right shift operations against. /// The minimum no. of items MUST be able to store after . - /// For performance reasons, MUST a power of 2. This simplifies a lot block & item + /// + /// For performance reasons, 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. + /// + /// This method checks for integral overflow. /// /// /// 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; diff --git a/Recyclable.Collections.Benchmarks/POC/RefVsInstanceMemberPoc.Benchmarks.cs b/Recyclable.Collections.Benchmarks/POC/RefVsInstanceMemberPoc.Benchmarks.cs index 3c9c429..bad353e 100644 --- a/Recyclable.Collections.Benchmarks/POC/RefVsInstanceMemberPoc.Benchmarks.cs +++ b/Recyclable.Collections.Benchmarks/POC/RefVsInstanceMemberPoc.Benchmarks.cs @@ -26,7 +26,7 @@ namespace Recyclable.Collections.Benchmarks.POC benchmark.RefToInt2(); benchmark.RefToInt3(); } - + private readonly TestCase _testCase = new(); private static void DoNothing(int count) { diff --git a/Recyclable.Collections.Benchmarks/POC/WhenParallelSearchBenchmarks.cs b/Recyclable.Collections.Benchmarks/POC/WhenParallelSearchBenchmarks.cs index 5e474ec..1a33945 100644 --- a/Recyclable.Collections.Benchmarks/POC/WhenParallelSearchBenchmarks.cs +++ b/Recyclable.Collections.Benchmarks/POC/WhenParallelSearchBenchmarks.cs @@ -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? _testData; public object? ItemToFind { get; set; } - [GlobalSetup] + [GlobalSetup] public void Setup() { _testData = Enumerable.Range(1, TestObjectCount).Cast().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++; diff --git a/Recyclable.Collections/MathUtils.cs b/Recyclable.Collections/MathUtils.cs index 40f2141..aebd3d6 100644 --- a/Recyclable.Collections/MathUtils.cs +++ b/Recyclable.Collections/MathUtils.cs @@ -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); diff --git a/Recyclable.Collections/RecyclableArrayList.cs b/Recyclable.Collections/RecyclableArrayList.cs index 8160579..3ab98d1 100644 --- a/Recyclable.Collections/RecyclableArrayList.cs +++ b/Recyclable.Collections/RecyclableArrayList.cs @@ -8,7 +8,6 @@ namespace Recyclable.Collections { private const int ItemNotFound = -1; private static readonly ArrayPool _arrayPool = ArrayPool.Create(); - private static readonly IEqualityComparer _equalityComparer = EqualityComparer.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 GetEnumerator() => Enumerate(this).GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() => Enumerate(this).GetEnumerator(); public void Dispose() diff --git a/Recyclable.Collections/RecyclableList.cs b/Recyclable.Collections/RecyclableList.cs index 28c1c67..a09658e 100644 --- a/Recyclable.Collections/RecyclableList.cs +++ b/Recyclable.Collections/RecyclableList.cs @@ -373,10 +373,11 @@ namespace Recyclable.Collections /// Minimal requested block size. It MUST be rounded to the power of 2, see remarks. /// Pre-calculated bit shifting value for left & right shift operations against. /// The minimum no. of items MUST be able to store after . - /// For performance reasons, MUST a power of 2. This simplifies a lot block & item + /// + /// For performance reasons, 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. + /// + /// This method checks for integral overflow. /// /// /// 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; diff --git a/Recyclable.Collections/RecyclableListExtensions.cs b/Recyclable.Collections/RecyclableListExtensions.cs index d7c3f9d..2823cf7 100644 --- a/Recyclable.Collections/RecyclableListExtensions.cs +++ b/Recyclable.Collections/RecyclableListExtensions.cs @@ -112,7 +112,7 @@ namespace Recyclable.Collections return scannedCount; } - scannedCount++; + scannedCount++; if (scannedCount == itemsCount) { return -1; diff --git a/Recyclable.Collections/RecyclableQueue.cs b/Recyclable.Collections/RecyclableQueue.cs index 0b48c3a..f8ff04a 100644 --- a/Recyclable.Collections/RecyclableQueue.cs +++ b/Recyclable.Collections/RecyclableQueue.cs @@ -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); } } diff --git a/Recyclable.Collections/RecyclableSortedList.cs b/Recyclable.Collections/RecyclableSortedList.cs index 1c64e82..c3e63bd 100644 --- a/Recyclable.Collections/RecyclableSortedList.cs +++ b/Recyclable.Collections/RecyclableSortedList.cs @@ -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); - } + } } } } \ No newline at end of file diff --git a/Recyclable.CollectionsTests/EnumerableWithoutCount.cs b/Recyclable.CollectionsTests/EnumerableWithoutCount.cs index b6c08b3..34df3e9 100644 --- a/Recyclable.CollectionsTests/EnumerableWithoutCount.cs +++ b/Recyclable.CollectionsTests/EnumerableWithoutCount.cs @@ -4,7 +4,7 @@ namespace Recyclable.CollectionsTests { public class EnumerableWithoutCount : IEnumerable { - private IEnumerable _testData; + private readonly IEnumerable _testData; public EnumerableWithoutCount(IEnumerable testData) { diff --git a/Recyclable.CollectionsTests/ItemRangesIteratorTests.cs b/Recyclable.CollectionsTests/ItemRangesIteratorTests.cs index 59715f8..fb9b33c 100644 --- a/Recyclable.CollectionsTests/ItemRangesIteratorTests.cs +++ b/Recyclable.CollectionsTests/ItemRangesIteratorTests.cs @@ -127,7 +127,6 @@ namespace Recyclable.CollectionsTests (9, 0, 1), } }, - }; } } diff --git a/Recyclable.CollectionsTests/RecyclableArrayListTests.cs b/Recyclable.CollectionsTests/RecyclableArrayListTests.cs index 7d236d8..66d6c01 100644 --- a/Recyclable.CollectionsTests/RecyclableArrayListTests.cs +++ b/Recyclable.CollectionsTests/RecyclableArrayListTests.cs @@ -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((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))); - } } } -} \ No newline at end of file +} \ No newline at end of file diff --git a/Recyclable.CollectionsTests/RecyclableListTestData.cs b/Recyclable.CollectionsTests/RecyclableListTestData.cs index 5f8b179..b4d17e3 100644 --- a/Recyclable.CollectionsTests/RecyclableListTestData.cs +++ b/Recyclable.CollectionsTests/RecyclableListTestData.cs @@ -54,7 +54,6 @@ namespace Recyclable.CollectionsTests CreateTestData(itemsCount).ToRecyclableList(sourceBlockSize), itemsCount }; - } yield return new object[] { $"IList(itemsCount: {itemsCount})", new CustomIList(CreateTestData(itemsCount)), itemsCount }; @@ -64,7 +63,7 @@ namespace Recyclable.CollectionsTests } public static IEnumerable SourceDataVariants => CreateSourceDataVariants().ToArray(); - + private static IEnumerable CreateSourceEmptyDataVariants() => new[] { new object[] { "int[]", Array.Empty() },