Click or drag to resize

Generator Class

Contains static methods for creating generators, and extension methods to create generators from existing ones.
Inheritance Hierarchy
SystemObject
  Gamelogic.Extensions.AlgorithmsGenerator

Namespace:  Gamelogic.Extensions.Algorithms
Assembly:  Assembly-CSharp (in Assembly-CSharp.dll) Version: 0.0.0.0
Syntax
C#
[VersionAttribute(2, 0, 0)]
public static class Generator

The Generator type exposes the following members.

Methods
  NameDescription
Public methodStatic memberAggregateTSource(IGeneratorTSource, FuncTSource, TSource, TSource)
Makes a generator that generates a running aggregate of the source generator.
Public methodStatic memberAggregateTSource(IGeneratorTSource, FuncTSource, TSource, TSource, TSource)
Makes a generator that generates a running aggregate of the source generator.
Public methodStatic memberCode exampleAggregateTSource, TResult(IGeneratorTSource, FuncTResult, TSource, TResult, TResult)
Makes a generator that generates a running aggregate of the source generator.
Public methodStatic memberCode exampleApplyTSource
Makes a generator that applies a function on the elements it generates.
Public methodStatic memberCode exampleAverage(IGeneratorInt32)
Makes a generator the will generate the average of elements generated by another generator.
Public methodStatic memberCode exampleAverage(IGeneratorSingle)
Makes a generator the will generate the average of elements generated by another generator.
Public methodStatic memberCastTResult
Makes a generator that will generate elements by casting the elements of a source generator.
Public methodStatic memberCode exampleChooseTSource(IListTSource, IGeneratorInt32)
Makes a generator that chooses elements from a list using an index generator.
Public methodStatic memberCode exampleChooseTSource(IListIGeneratorTSource, IGeneratorInt32)
Makes a generator that uses an index generator to choose a generator to generate an element from.
Public methodStatic memberChooseUniformRandomTSource(IListTSource)
Make a generator that randomly generates elements from a list.
Public methodStatic memberChooseUniformRandomTSource(IGeneratorTSource) Obsolete.
Chooses the from the given generators selected uniform randomly.
Public methodStatic memberChooseUniformRandomTSource(IListIGeneratorTSource)
Makes a generator that selects a random generator from a given element to generate an element from.
Public methodStatic memberChooseUniformRandomTSource(IListTSource, Int32)
Make a generator that randomly generates elements from a list. Can be seeded.
Public methodStatic memberChooseUniformRandomTSource(IListIGeneratorTSource, Int32)
Chooses the random.
Public methodStatic memberClosedSawTooth
Makes a generator that produces evenly spaced floats from 0 to 1, both limits included, and repeats the result.
Public methodStatic memberCombineTSource, TResult(IEnumerableIGeneratorTSource, FuncIListTSource, TResult)
Makes a generator that combines the elements of specified generators.
Public methodStatic memberCode exampleCombineT1, T2, TResult(IGeneratorT1, IGeneratorT2, FuncT1, T2, TResult)
Combines the specified generators by applying a result selector function to the elements of each generator.
Public methodStatic memberCombineT1, T2, T3, TResult(IGeneratorT1, IGeneratorT2, IGeneratorT3, FuncT1, T2, T3, TResult)
Combines the specified generators by applying a result selector function to the elements of each generator.
Public methodStatic memberCombineT1, T2, T3, T4, TResult(IGeneratorT1, IGeneratorT2, IGeneratorT3, IGeneratorT4, FuncT1, T2, T3, T4, TResult)
Combines the specified generators by applying a result selector function to the elements of each generator.
Public methodStatic memberConstantTSource
Makes a generator that generates a the same item each time.
Public methodStatic memberCount
Makes a generator that generates consecutive integers starting from zero up to a limit, and repeats the cycle.
Public methodStatic memberDither
Takes the source generator's output, and generate a dithered sequence of integers in the range 0 to levels - 1. Uses error diffusion.
Public methodStatic memberFrequencyRandomInt(IEnumerableSingle)
Generates random integers at relative frequencies provided.
Public methodStatic memberFrequencyRandomInt(IEnumerableSingle, Int32)
Generates random integers at relative frequencies provided.
Public methodStatic memberFromFuncTResult
Makes a new generator from a generator function.
Public methodStatic memberGaussianRandomFloat
Makes a generator that generates floats with a Gaussian distribution.
Public methodStatic memberGroupTSource(IGeneratorTSource, IGeneratorInt32)
Makes a generator that generates groups of items from the source generator.
Public methodStatic memberGroupTSource(IGeneratorTSource, Int32)
Makes a generator that returns groups of elements from the source generator.
Public methodStatic memberInterleaveTSource(IListIGeneratorTSource)
Makes a generator that interleaves the elements of the specified generators.
Public methodStatic memberInterleaveTSource(IGeneratorTSource, IGeneratorTSource)
Makes a generator that interleaves the elements of the specified generators.
Public methodStatic memberInterpolateTSource(IGeneratorTSource, IGeneratorInt32, FuncTSource, TSource, Single, TSource)
Makes a generator that interpolates between values of a given generator.
Public methodStatic memberCode exampleInterpolateTSource(IGeneratorTSource, Int32, FuncTSource, TSource, Single, TSource)
Makes a generator that interpolates between values of a given generator.
Public methodStatic memberInterpolateDitherTSource
Interpolates a sequence, but applies dithering.
Public methodStatic memberIterateTSource(IEnumerableTSource, FuncIListTSource, TSource)
Makes a generator that uses an iterator function to generate elements.
Public methodStatic memberIterateTSource(TSource, FuncTSource, TSource)
Makes a generator that returns iterations of the specified initial element.
Public methodStatic memberIterateTSource(TSource, TSource, FuncTSource, TSource, TSource)
Makes a generator that uses an iterator function to generate elements.
Public methodStatic memberIterateTSource(TSource, TSource, TSource, FuncTSource, TSource, TSource, TSource)
Makes a generator that uses an iterator function to generate elements.
Public methodStatic memberIterateTSource(TSource, TSource, TSource, TSource, FuncTSource, TSource, TSource, TSource, TSource)
Makes a generator that uses an iterator function to generate elements.
Public methodStatic memberIterateTSource, TSource2(TSource, IGeneratorTSource2, FuncTSource, TSource2, TSource)
Applies a function on the last element to produce the next element. The function takes twp parameters; the second parameter is supplied by a generator.
Public methodStatic memberLogTSource(IGeneratorTSource)
A generator that generates the elements of the source generator, but sends the generated element to the Unity Console.
Public methodStatic memberCode exampleLogTSource(IGeneratorTSource, ActionTSource)
A generator that generates the elements of the source generator, but applies a log function to each element as it is generated.
Public methodStatic memberMarkovRandomInt(Single)
Generates a Markov chain of integers from a transition table.
Public methodStatic memberMarkovRandomInt(Single, Int32)
Generates a Markov chain of integers from a transition table.
Public methodStatic memberMarkovRandomIntStartsWith(Single, Int32)
Makes a Markov generator that starts with the given value.
Public methodStatic memberMarkovRandomIntStartsWith(Single, Int32, Int32)
Makes a Markov generator that starts with the given value.
Public methodStatic memberMoveNextTSource
Moves the generator by a specified amount forward.
Public methodStatic memberNextTSource(IGeneratorTSource)
Returns the next element of the specified generator.
Public methodStatic memberNextTSource(IGeneratorTSource, Int32)
Returns a list of the next n items from the generator.
Public methodStatic memberCode exampleNextWhileTSource
Generates the elements from the generator while the predicate applied to elements hold an return them in an enumerable. After calling this method, the next element returned by Next (or the current value of Current) will not satisfy the predicate.
Public methodStatic memberOfTypeTResult
Makes a generator that will generate elements of a source generator that is of the given type.
Public methodStatic memberOpenSawTooth(Int32)
Makes a generator that produces evenly spaced floats from 0 (included) to 1 (excluded), and repeats the result.
Public methodStatic memberOpenSawTooth(IGeneratorInt32)
Makes a generator that produces evenly spaced floats from 0 (included) to 1 (excluded), and repeats the result (but with the number of samples each time given by a generator).
Public methodStatic memberCode examplePadTSource(IGeneratorTSource, IEnumerableTSource)
Pads the specified generator with elements from a given list.
Public methodStatic memberCode examplePadTSource(IGeneratorTSource, TSource, Int32)
Pads the specified generator with a constant element repeated a specified number of times.
Public methodStatic memberPoisson
A boolean generator that returns true at intervals uniformly distributed between minRadius and maxRadius.
Public methodStatic memberRandomBoolGenerator(Single)
Makes a generator that returns random boolean values, true with the specified probability.
Public methodStatic memberRandomBoolGenerator(Single, Int32)
Makes a generator that returns random boolean values, true with the specified probability.
Public methodStatic memberRepeatTSource
Makes a generator that repeats elements of the given list over and over.
Public methodStatic memberRepeatEachTSource(IGeneratorTSource, IGeneratorInt32)
Makes a new generator that will repeat each of the given generators elements a number of times.
Public methodStatic memberRepeatEachTSource(IGeneratorTSource, Int32)
Makes a new generator that will repeat each of the given generators elements a number of times.
Public methodStatic memberSelectTResult(IGeneratorSingle, ResponseCurveBaseTResult)
Makes a new generator by transforming the elements of a given float generator using a response curve.
Public methodStatic memberSelectTSource, TResult(IGeneratorTSource, FuncTSource, TResult)
Makes a generator which generates items that are transformed, generated from a given generator.
Public methodStatic memberSelectManyTSource, TResult
For each item in the source generator, a list of items is generated, but the items are generated one by one (and not as a list of items).
Public methodStatic memberCode exampleSkipTSource
Makes a generator that skips over the specified number of elements from the source generator.
Public methodStatic memberCode exampleSkipAndTakeTSource
Makes a generator that repeatedly skips over and takes elements from a given generator.
Public methodStatic memberCode exampleSum(IGeneratorInt32)
Makes a generator that will generate partial sums of a given generator.
Public methodStatic memberCode exampleSum(IGeneratorSingle)
Makes a generator that will generate partial sums of a given generator.
Public methodStatic memberSwitchAfterTSource
Generates elements from a source generator for the given number of steps, then switches to a second generator.
Public methodStatic memberSwitchWhenTSource
Generates elements from the source generator until a condition is met, then generate elements from a second generator.
Public methodStatic memberCode exampleTakeAndSkipTSource
Makes a generator that repeatedly takes and skips over elements from a given generator.
Public methodStatic memberUniformRandomFloat
Makes a generator hat generates floats uniformly between 0 and 1.
Public methodStatic memberUniformRandomFloat(Int32)
Makes a generator that generates floats uniformly between 0 and 1.
Public methodStatic memberUniformRandomInt(Int32)
Makes a generator that generates integers uniformly distributed between 0 (included) and the specified limit (excluded).
Public methodStatic memberUniformRandomInt(Int32, Int32)
Makes a generator hat generates integers uniformly distributed between 0 (included) and the specified limit (excluded).
Public methodStatic memberUniformVector2InCircle
Generates vectors uniformly distributed in a given circle.
Public methodStatic memberUniformVector2InRect
Generates vectors uniformly distributed in a given rectangle.
Public methodStatic memberWhereTSource(IGeneratorTSource, IGeneratorBoolean)
Makes a generator that will only generate elements that pass the predicate generated by the predicate generator.
Public methodStatic memberWhereTSource(IGeneratorTSource, FuncTSource, Boolean)
Makes a generator that will only generate elements that pass the predicate.
Public methodStatic memberWhereT(IGeneratorT, IGeneratorBoolean, Int32)
Makes a generator that will only generate elements that pass the predicate generated by the predicate generator. If the source elements does not provide elements that pass the predicate for the given number of maximum iterations, an exception is thrown. This is to prevent a stalling the generator forever.
Public methodStatic memberWhereT(IGeneratorT, FuncT, Boolean, Int32)
Makes a generator that will only generate elements that pass the predicate. If the source elements does not provide elements that pass the predicate for the given number of maximum iterations, an exception is thrown. This is to prevent a stalling the generator forever.
Public methodStatic memberWhereWindowTSource
Only generates an item if the window of the item passes the predicate.
Public methodStatic memberCode exampleWindowTSource
Makes a generator that generates a moving window of elements over a given generator.
Top
Remarks
A generator is a class that generates data on demand. In this implementation, generators implement the IGenerator interface, and through an extension method supports a Next method that returns an element every time it is called. Generators are infinite. Many methods make methods from existing generators. The existing generators are always cloned, so no derived generator will call the Next or MoveNext methods of an existing generator. Clones are always returned in the restarted state. Although Generators have almost the same interface as IEnumerator, there are some differences. Generators are always in a "valid" state, so calls to Current will always return a valid result, there is no "before first" and "after last" states. You can also implement your own generators. There are two ways to do this. The first is to simply use the static methods provided; they allow you to make new generators by manipulating existing ones. The second way is appropriate for more complicated situations, and that is to define your own class that implements the IGenerator<T> interface. IGeneratorTResult
See Also