C#: Add IntegerCollection class to the CollectionFlow tests and update line numbers in expected test output.

This commit is contained in:
Michael Nebel
2024-01-29 14:28:05 +01:00
parent da4a9b620a
commit cd5f678e1c
2 changed files with 601 additions and 576 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
@@ -448,4 +449,28 @@ public class CollectionFlow
A[] array = [.. temp];
Sink(array[0]); // flow
}
[System.Runtime.CompilerServices.CollectionBuilder(typeof(IntegerCollectionBuilder), "Create")]
public class IntegerCollection : IEnumerable<int>
{
private int[] items;
public A? Payload { get; set; }
public IntegerCollection(ReadOnlySpan<int> items)
{
this.items = items.ToArray();
Payload = null;
}
public IEnumerator<int> GetEnumerator() => items.AsEnumerable<int>().GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => items.GetEnumerator();
}
public static class IntegerCollectionBuilder
{
public static IntegerCollection Create(ReadOnlySpan<int> elements)
=> new IntegerCollection(elements);
}
}