diff --git a/Recyclable.Collections.TestData/Recyclable.Collections.TestData.csproj b/Recyclable.Collections.TestData/Recyclable.Collections.TestData.csproj
index fdca3cd..9b60f3e 100644
--- a/Recyclable.Collections.TestData/Recyclable.Collections.TestData.csproj
+++ b/Recyclable.Collections.TestData/Recyclable.Collections.TestData.csproj
@@ -34,7 +34,8 @@
-
+
+
diff --git a/Recyclable.Collections.TestData/RecyclableLongListTestData.cs b/Recyclable.Collections.TestData/RecyclableLongListTestData.cs
index 093856e..e22bd3c 100644
--- a/Recyclable.Collections.TestData/RecyclableLongListTestData.cs
+++ b/Recyclable.Collections.TestData/RecyclableLongListTestData.cs
@@ -12,24 +12,57 @@ namespace Recyclable.Collections.TestData
static IEnumerable<(long ItemIndex, long RangeItemsCount)> GenerateRanges(long itemIndex, long itemsCount)
{
yield return (0L, Math.Max(itemIndex, 1L));
- yield return (itemIndex, Math.Max(itemsCount - itemIndex, 1L));
+ yield return (itemIndex, itemsCount - itemIndex);
yield return (itemIndex, 1L);
- yield return (Math.Max(0L, itemIndex - 1L), Math.Max(Math.Min(itemsCount - itemIndex, 2L), 1L));
yield return (0L, 0L);
yield return (itemIndex, 0L);
- yield return (Math.Max(0L, itemIndex - 1L), 0L);
yield return (0L, 1L);
- yield return (0L, Math.Max(itemIndex, 1L));
yield return (0L, Math.Max(itemsCount - itemIndex, 1L));
- yield return (0L, 2L);
-
+
var rangeSize = (int)Math.Min(itemsCount - itemIndex, 4);
yield return ((int)(rangeSize > 2 ? Math.Max(0, itemIndex - 2) : itemIndex), rangeSize);
rangeSize = (int)Math.Max(Math.Min(itemsCount - itemIndex - 2, 4), 0);
yield return ((int)(rangeSize > 2 ? Math.Max(0, itemIndex - 2 - 1) : Math.Max(0, itemIndex - 1)), rangeSize);
+
+ if (itemsCount > 1)
+ {
+ yield return (0L, 2L);
+ }
+
+ if (itemIndex > 0)
+ {
+
+ if (itemIndex > 1)
+ {
+ yield return (0L, itemIndex);
+
+ }
+
+ yield return (itemIndex - 1, 0L);
+
+ if (itemsCount > 1)
+ {
+ yield return (itemIndex - 1, 2);
+ }
+
+ if (itemsCount > 2)
+ {
+ yield return (itemIndex - 1, Math.Min(3, itemsCount - itemIndex + 1));
+ }
+
+ if (itemsCount > 3)
+ {
+ yield return ((int)(itemIndex - 1), (int)Math.Min(itemIndex + 1, itemsCount - itemIndex + 1));
+ }
+
+ if (itemIndex >= RecyclableDefaults.MinItemsCountForParallelization)
+ {
+ yield return (itemIndex - RecyclableDefaults.MinItemsCountForParallelization, (int)Math.Min(itemsCount - itemIndex + RecyclableDefaults.MinItemsCountForParallelization, itemIndex + RecyclableDefaults.MinItemsCountForParallelization));
+ }
+ }
}
}
@@ -153,6 +186,11 @@ namespace Recyclable.Collections.TestData
public static IEnumerable CreateItemIndexVariants(long itemsCount, int blockSize)
{
+ if (itemsCount == 0)
+ {
+ return Enumerable.Empty();
+ }
+
IEnumerable primes = InitialItemIndexVariants.Concat(
InitialItemIndexVariants.SelectMany(index => new long[] { blockSize - index, blockSize + index })
//new long[] { blockSize - 3, blockSize - 2, blockSize - 1, blockSize, blockSize + 1, blockSize + 2, blockSize + 3 }
@@ -166,11 +204,16 @@ namespace Recyclable.Collections.TestData
primes = primes.Concat(second).ToArray();
- primes = primes.Concat(
- primes.Select(index => itemsCount - index - 1)
- )
- .Where(index => itemsCount > 0 && index >= 0 && index < itemsCount).ToArray()
- .Distinct().ToArray();
+ primes = primes
+ .Concat(primes
+ .Select(index => itemsCount - index - 1))
+ .Concat(primes
+ .Where(index => index >= RecyclableDefaults.MinItemsCountForParallelization)
+ .Select(index => index - RecyclableDefaults.MinItemsCountForParallelization))
+ .Where(index => index >= 0 && index < itemsCount)
+ .ToArray()
+ .Distinct()
+ .ToArray();
return primes;
@@ -363,6 +406,8 @@ namespace Recyclable.Collections.TestData
1, 2, 4, 16, RecyclableDefaults.MinPooledArrayLength - 5, (int)BitOperations.RoundUpToPowerOf2(RecyclableDefaults.MinPooledArrayLength)
};
+ public static IEnumerable