Class Yielding
Provides helper methods for handling yielded values from factory methods.
public static class Yielding
- Inheritance
-
Yielding
- Inherited Members
Methods
Fill<T>(Memory<T>, Func<T>)
Fills the contents of an existing instance of Memory<T> with yielded values from the currently provided factory.
public static Memory<T> Fill<T>(this Memory<T> span, Func<T> factory)
Parameters
Returns
Type Parameters
T
Fill<T>(Span<T>, Func<T>)
Fills the contents of an existing instance of Span<T> with yielded values from the currently provided factory.
public static Span<T> Fill<T>(this Span<T> span, Func<T> factory)
Parameters
spanSpan<T>The Span<T> instance to yield the values into.
factoryFunc<T>The factory method whose values will be yielded.
Returns
Type Parameters
T
Fill<T>(T[], Func<T>)
Fills the contents of an existing array with yielded values from the currently provided factory.
public static T[] Fill<T>(this T[] span, Func<T> factory)
Parameters
spanT[]factoryFunc<T>The factory method whose values will be yielded.
Returns
- T[]
The provided array.
Type Parameters
T
For<T>(Func<T>)
Creates a new Yielder<T> from a factory method.
public static Yielder<T> For<T>(Func<T> factory)
Parameters
factoryFunc<T>The factory method whose values will be yielded.
Returns
- Yielder<T>
The new Yielder<T> instance with the provided underlying factory method.
Type Parameters
TThe type of the yielded values.
Remarks
Factory is mutable, and the underlying factory method may be changed from another external source.
YieldArray<T>(int, Func<T>)
Yields a number of values into a new array.
public static T[] YieldArray<T>(int count, Func<T> factory)
Parameters
countintThe number of values to yield.
factoryFunc<T>The factory method whose values will be yielded.
Returns
- T[]
The created array containing the yielded values in the order they were yielded.
Type Parameters
T
YieldImmutableArray<T>(int, Func<T>)
Yields a number of values into a new instance of ImmutableArray<T>.
public static ImmutableArray<T> YieldImmutableArray<T>(int count, Func<T> factory)
Parameters
countintThe number of values to yield.
factoryFunc<T>The factory method whose values will be yielded.
Returns
- ImmutableArray<T>
The created ImmutableArray<T> instance containing the yielded values in the order they were yielded.
Type Parameters
T
YieldInto<T>(int, Func<T>, HashSet<T>)
Yields a number of values into an existing instance of HashSet<T>.
public static HashSet<T> YieldInto<T>(int count, Func<T> factory, HashSet<T> set)
Parameters
countintThe number of values to yield.
factoryFunc<T>The factory method whose values will be yielded.
setHashSet<T>The HashSet<T> instance to yield the values into.
Returns
- HashSet<T>
The provided HashSet<T> instance.
Type Parameters
T
YieldInto<T>(int, Func<T>, List<T>)
Yields a number of values into an existing instance of List<T>.
public static List<T> YieldInto<T>(int count, Func<T> factory, List<T> list)
Parameters
countintThe number of values to yield.
factoryFunc<T>The factory method whose values will be yielded.
listList<T>The List<T> instance to yield the values into.
Returns
Type Parameters
T
YieldInto<T>(int, Func<T>, SortedSet<T>)
Yields a number of values into an existing instance of SortedSet<T>.
public static SortedSet<T> YieldInto<T>(int count, Func<T> factory, SortedSet<T> set)
Parameters
countintThe number of values to yield.
factoryFunc<T>The factory method whose values will be yielded.
setSortedSet<T>The SortedSet<T> instance to yield the values into.
Returns
- SortedSet<T>
The provided SortedSet<T> instance.
Type Parameters
T
Remarks
This method first creates a new List<T> using YieldList(int), and then performs a union on SortedSet<T> with the created list. This approach is considered to be more optimal.
YieldList<T>(int, Func<T>)
Yields a number of values into a new instance of List<T>.
public static List<T> YieldList<T>(int count, Func<T> factory)
Parameters
countintThe number of values to yield.
factoryFunc<T>The factory method whose values will be yielded.
Returns
Type Parameters
T
YieldOnto<T>(HashSet<T>, int, Func<T>)
Yields a number of values into an existing instance of HashSet<T>.
public static HashSet<T> YieldOnto<T>(this HashSet<T> set, int count, Func<T> factory)
Parameters
setHashSet<T>The HashSet<T> instance to yield the values into.
countintThe number of values to yield.
factoryFunc<T>The factory method whose values will be yielded.
Returns
- HashSet<T>
The provided HashSet<T> instance.
Type Parameters
T
YieldOnto<T>(List<T>, int, Func<T>)
Yields a number of values into an existing instance of List<T>.
public static List<T> YieldOnto<T>(this List<T> list, int count, Func<T> factory)
Parameters
listList<T>The List<T> instance to yield the values into.
countintThe number of values to yield.
factoryFunc<T>The factory method whose values will be yielded.
Returns
Type Parameters
T
YieldOnto<T>(SortedSet<T>, int, Func<T>)
Yields a number of values into an existing instance of SortedSet<T>.
public static SortedSet<T> YieldOnto<T>(this SortedSet<T> set, int count, Func<T> factory)
Parameters
setSortedSet<T>The SortedSet<T> instance to yield the values into.
countintThe number of values to yield.
factoryFunc<T>The factory method whose values will be yielded.
Returns
- SortedSet<T>
The provided SortedSet<T> instance.
Type Parameters
T
Remarks
This method first creates a new List<T> using YieldList(int), and then performs a union on SortedSet<T> with the created list. This approach is considered to be more optimal.
YieldSet<T>(int, Func<T>)
Yields a number of values into a new instance of HashSet<T>.
public static HashSet<T> YieldSet<T>(int count, Func<T> factory)
Parameters
countintThe number of values to yield.
factoryFunc<T>The factory method whose values will be yielded.
Returns
- HashSet<T>
The created HashSet<T> instance containing the yielded values.
Type Parameters
T
Remarks
Duplicate yielded values are ignored. If the provided factory method can yield duplicate values, the count may be less than the provided.
YieldSortedSet<T>(int, Func<T>)
Yields a number of values into a new instance of SortedSet<T>.
public static SortedSet<T> YieldSortedSet<T>(int count, Func<T> factory)
Parameters
countintThe number of values to yield.
factoryFunc<T>The factory method whose values will be yielded.
Returns
- SortedSet<T>
The created SortedSet<T> instance containing the yielded values.
Type Parameters
T
Remarks
This method first creates a new List<T> using YieldList(int), and then constructs the SortedSet<T> out of the created list. This approach is considered to be more optimal.
Yield<T>(int, Func<T>)
Yields values out of the factory without storing them anywhere.
public static IEnumerable<T> Yield<T>(int count, Func<T> factory)
Parameters
countintThe number of values to yield from the factory.
factoryFunc<T>The factory method whose values will be yielded.
Returns
- IEnumerable<T>
A IEnumerable<T> with the yielded values from the provided factory.
Type Parameters
T