Table of Contents

Struct Yielder<T>

Namespace
Garyon.Objects
Assembly
Garyon.dll

Provides mechanisms for convenient yielding of a factory's values.

public record struct Yielder<T> : IEquatable<Yielder<T>>

Type Parameters

T

The type of the yielded values.

Implements
Inherited Members
Extension Methods

Constructors

Yielder(Func<T>)

Provides mechanisms for convenient yielding of a factory's values.

public Yielder(Func<T> Factory)

Parameters

Factory Func<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

memory Memory<T>

The Memory<T> instance to yield the values into.

Returns

Memory<T>

The provided Memory<T> instance.

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

span Span<T>

The Span<T> instance to yield the values into.

Returns

Span<T>

The provided Span<T> instance.

Fill(T[])

Fills the contents of an existing array with yielded values from the currently provided factory.

public T[] Fill(T[] array)

Parameters

array T[]

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

count int

The 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

count int

The 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

count int

The 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

count int

The number of values to yield.

set HashSet<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

count int

The number of values to yield.

list List<T>

The List<T> instance to yield the values into.

Returns

List<T>

The provided List<T> instance.

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

count int

The number of values to yield.

set SortedSet<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

count int

The number of values to yield.

memory Memory<T>

The Memory<T> instance to yield the values into.

Returns

Memory<T>

The provided Memory<T> instance.

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

count int

The number of values to yield.

span Span<T>

The Span<T> instance to yield the values into.

Returns

Span<T>

The provided Span<T> instance.

YieldList(int)

Yields a number of values into a new instance of List<T>.

public List<T> YieldList(int count)

Parameters

count int

The number of values to yield.

Returns

List<T>

The created List<T> instance containing the yielded values in the order they were yielded.

YieldSet(int)

Yields a number of values into a new instance of HashSet<T>.

public HashSet<T> YieldSet(int count)

Parameters

count int

The 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

count int

The 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.