Skip to content

Commit 3b1b158

Browse files
committed
fix
1 parent 17cb8dc commit 3b1b158

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

Eocron.Algorithms/SpaceCurves/ZCurve.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Eocron.Algorithms.SpaceCurves
66
{
77
public static class ZCurve
88
{
9-
public static T[] Interleave<T>(IReadOnlyList<T> items, int m)
9+
public static T[] Interleave<T>(IReadOnlyCollection<T> items, int m)
1010
{
1111
return Interleave<T>(items, items.Count, m);
1212
}
@@ -29,15 +29,17 @@ public static T[] Interleave<T>(IEnumerable<T> items, int size, int m)
2929
return output;
3030
}
3131

32-
public static T[] Interleave<T>(params IReadOnlyList<T>[] itemSequences)
32+
public static T[] Interleave<T>(params IReadOnlyCollection<T>[] itemSequences)
3333
{
34-
if (itemSequences.Select(x=> x.Count).Distinct().Count()>1)
34+
var itemSize = itemSequences[0].Count;
35+
if (itemSequences.Any(x=> x.Count != itemSize))
3536
{
3637
throw new ArgumentOutOfRangeException(nameof(itemSequences), "Sequences should have same size");
3738
}
3839

3940
var m = itemSequences.Length;
40-
return Interleave(itemSequences.SelectMany(x => x), itemSequences.Sum(x => x.Count), m);
41+
42+
return Interleave(itemSequences.SelectMany(x => x), itemSize * m, m);
4143
}
4244

4345
public static int GetInterleavedIndex(int idx, int n, int m)

0 commit comments

Comments
 (0)