Click or drag to resize

BcfIntSequence Class

[This is preliminary documentation and is subject to change.]

A sequence returning integers.
Inheritance Hierarchy
SystemObject
  CalculationWorks.BusinessModelBcfIntSequence

Namespace:  CalculationWorks.BusinessModel
Assembly:  CalculationWorks.BusinessModel (in CalculationWorks.BusinessModel.dll) Version: 4.0.0-beta7
Syntax
public class BcfIntSequence : IBcfSequence<int>

The BcfIntSequence type exposes the following members.

Constructors
  NameDescription
Public methodBcfIntSequence
Creates a new instance.
Top
Methods
  NameDescription
Public methodAccept
Called when a value was applied (May be from out-side by setting a value or loading a row).
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodNext
Returns the next value from the sequence.
Public methodReset
Resets the sequence to its initial state.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Examples
Implementing IBcfSequence<T>
  public class BcfIntSequence : IBcfSequence<int> {
    private int _current;
    private readonly int _start;
    private readonly int _step;

    public BcfIntSequence(int start = 0, int step = 1) {
        if(step == 0) throw new ArgumentException("Zero is not a valid step.", nameof(step));
        _start = start;
        _step = step;
        Reset();
    }

    public int Next(BcfColumn<int> column) {
        _current += _step;
        return _current;
    }

    public void Accept(BcfColumn<int> column, int value) {
        if (_step > 0 && value > _current) _current = value;
        if (_step < 0 && value < _current) _current = value;
    }

    public void Reset() {
        _current = _start - _step;
    }
}
See Also