Table of Contents

Class Yielding

Namespace
Garyon.Objects
Assembly
Garyon.dll

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

span Memory<T>
factory Func<T>

The factory method whose values will be yielded.

Returns

Memory<T>

The provided Memory<T> instance.

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

span Span<T>

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

factory Func<T>

The factory method whose values will be yielded.

Returns

Span<T>

The provided Span<T> instance.

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

span T[]
factory Func<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

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

T

The 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

count int

The number of values to yield.

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

count int

The number of values to yield.

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

count int

The number of values to yield.

factory Func<T>

The factory method whose values will be yielded.

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

count int

The number of values to yield.

factory Func<T>

The factory method whose values will be yielded.

list List<T>

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

Returns

List<T>

The provided List<T> instance.

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

count int

The number of values to yield.

factory Func<T>

The factory method whose values will be yielded.

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

count int

The number of values to yield.

factory Func<T>

The factory method whose values will be yielded.

Returns

List<T>

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

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

set HashSet<T>

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

count int

The number of values to yield.

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

list List<T>

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

count int

The number of values to yield.

factory Func<T>

The factory method whose values will be yielded.

Returns

List<T>

The provided List<T> instance.

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

set SortedSet<T>

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

count int

The number of values to yield.

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

count int

The number of values to yield.

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

count int

The number of values to yield.

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

count int

The number of values to yield from the factory.

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