Struct Yielder<T>
Provides mechanisms for convenient yielding of a factory's values.
public record struct Yielder<T> : IEquatable<Yielder<T>>
Type Parameters
TThe type of the yielded values.
- Implements
-
IEquatable<Yielder<T>>
- Inherited Members
- Extension Methods
Constructors
Yielder(Func<T>)
Provides mechanisms for convenient yielding of a factory's values.
public Yielder(Func<T> Factory)
Parameters
FactoryFunc<T>The factory that will be used to yield values. You may change this during the lifetime of this instance.
Properties
Factory
The factory that will be used to yield values. You may change this during the lifetime of this instance.
public Func<T> Factory { readonly get; set; }
Property Value
- Func<T>
Methods
Fill(Memory<T>)
Fills the contents of an existing instance of Memory<T> with yielded values from the currently provided factory.
public Memory<T> Fill(Memory<T> memory)
Parameters
Returns
Fill(Span<T>)
Fills the contents of an existing instance of Span<T> with yielded values from the currently provided factory.
public Span<T> Fill(Span<T> span)
Parameters
Returns
Fill(T[])
Fills the contents of an existing array with yielded values from the currently provided factory.
public T[] Fill(T[] array)
Parameters
arrayT[]The array to yield the values into.
Returns
- T[]
The provided array.
Yield(int)
Yields values out of the factory without storing them anywhere.
public IEnumerable<T> Yield(int count)
Parameters
countintThe number of values to yield from the factory.
Returns
- IEnumerable<T>
A IEnumerable<T> with the yielded values from the current Factory.
Remarks
As Factory is mutable, the yielded results from the resulting IEnumerable<T> could use multiple factories, if adjusted from another external source.
YieldArray(int)
Yields a number of values into a new array.
public T[] YieldArray(int count)
Parameters
countintThe number of values to yield.
Returns
- T[]
The created array containing the yielded values in the order they were yielded.
YieldImmutableArray(int)
Yields a number of values into a new instance of ImmutableArray<T>.
public ImmutableArray<T> YieldImmutableArray(int count)
Parameters
countintThe number of values to yield.
Returns
- ImmutableArray<T>
The created ImmutableArray<T> instance containing the yielded values in the order they were yielded.
YieldInto(int, HashSet<T>)
Yields a number of values into an existing instance of HashSet<T>.
public HashSet<T> YieldInto(int count, HashSet<T> set)
Parameters
countintThe number of values to yield.
setHashSet<T>The HashSet<T> instance to yield the values into.
Returns
- HashSet<T>
The provided HashSet<T> instance.
YieldInto(int, List<T>)
Yields a number of values into an existing instance of List<T>.
public List<T> YieldInto(int count, List<T> list)
Parameters
countintThe number of values to yield.
listList<T>The List<T> instance to yield the values into.
Returns
YieldInto(int, SortedSet<T>)
Yields a number of values into an existing instance of SortedSet<T>.
public SortedSet<T> YieldInto(int count, SortedSet<T> set)
Parameters
countintThe number of values to yield.
setSortedSet<T>The SortedSet<T> instance to yield the values into.
Returns
- SortedSet<T>
The provided SortedSet<T> instance.
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.
YieldInto(int, Memory<T>)
Yields a number of values into an existing instance of Memory<T>.
public Memory<T> YieldInto(int count, Memory<T> memory)
Parameters
countintThe number of values to yield.
memoryMemory<T>The Memory<T> instance to yield the values into.
Returns
YieldInto(int, Span<T>)
Yields a number of values into an existing instance of Span<T>.
public Span<T> YieldInto(int count, Span<T> span)
Parameters
countintThe number of values to yield.
spanSpan<T>The Span<T> instance to yield the values into.
Returns
YieldList(int)
Yields a number of values into a new instance of List<T>.
public List<T> YieldList(int count)
Parameters
countintThe number of values to yield.
Returns
YieldSet(int)
Yields a number of values into a new instance of HashSet<T>.
public HashSet<T> YieldSet(int count)
Parameters
countintThe number of values to yield.
Returns
- HashSet<T>
The created HashSet<T> instance containing the yielded values.
Remarks
Duplicate yielded values are ignored. If the provided factory method can yield duplicate values, the count may be less than the provided.
YieldSortedSet(int)
Yields a number of values into a new instance of SortedSet<T>.
public SortedSet<T> YieldSortedSet(int count)
Parameters
countintThe number of values to yield.
Returns
- SortedSet<T>
The created SortedSet<T> instance containing the yielded values.
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.