Class FixedSequenceGenerator
- Namespace
- LfrlAnvil.Generators
- Assembly
- LfrlAnvil.Core.dll
Represents Fixed sequence generator of values within specified range.
public class FixedSequenceGenerator : SequenceGeneratorBase<Fixed>, ISequenceGenerator<Fixed>, IBoundGenerator<Fixed>, IGenerator<Fixed>, IGenerator
- Inheritance
-
FixedSequenceGenerator
- Implements
- Inherited Members
- Extension Methods
Constructors
FixedSequenceGenerator(Bounds<Fixed>)
Creates a new FixedSequenceGenerator instance that starts with
minimum possible value defined by bounds
, with Step equal to 1.
public FixedSequenceGenerator(Bounds<Fixed> bounds)
Parameters
FixedSequenceGenerator(Bounds<Fixed>, Fixed, Fixed?)
Creates a new FixedSequenceGenerator instance.
public FixedSequenceGenerator(Bounds<Fixed> bounds, Fixed start, Fixed? step = null)
Parameters
bounds
Bounds<Fixed>Range of values that can be generated.
start
FixedNext value to generate.
step
Fixed?Difference between two consecutively generated values. Equal to 1 with
start
precision by default.
Exceptions
- ArgumentOutOfRangeException
When
bounds
do not containstart
.- ArgumentException
When
step
is equal to 0.
FixedSequenceGenerator(Fixed, Fixed?)
Creates a new FixedSequenceGenerator instance with greatest possible Bounds.
public FixedSequenceGenerator(Fixed start, Fixed? step = null)
Parameters
start
FixedNext value to generate.
step
Fixed?Difference between two consecutively generated values. Equal to 1 with
start
precision by default.
Exceptions
- ArgumentException
When
step
is equal to 0.
FixedSequenceGenerator(byte)
Creates a new FixedSequenceGenerator instance that starts with 0, with Step equal to 1 and with greatest possible Bounds.
public FixedSequenceGenerator(byte decimals = 0)
Parameters
decimals
bytePrecision of generated values. Equal to 0 by default.
Exceptions
- ArgumentOutOfRangeException
When
decimals
is not a valid Fixed precision.
Methods
AddStep(Fixed)
Adds Step to the previously generated value in order to calculate the next value to generate.
protected override sealed Fixed AddStep(Fixed value)
Parameters
value
FixedPreviously generated value.
Returns
- Fixed
Next value to generate.
Exceptions
- OverflowException
When an arithmetic overflow occurred.