/// <summary> /// Creates an iterator over the given range with the given step function, /// with the specified direction. /// </summary> public LambdaRangeEnumerator([NotNull] LambdaRange <T> range, [NotNull] Func <T, T> step, bool ascending) { if (ascending && range.Comparer.Compare(range.Minimum, step(range.Minimum)) >= 0 || !ascending && range.Comparer.Compare(range.Maximum, step(range.Maximum)) <= 0) { throw new ArgumentException("step does nothing, or progresses the wrong way."); } _step = step; if (ascending) { _includesStart = range.IncludesStart; _includesEnd = range.IncludesEnd; _start = range.Minimum; _end = range.Maximum; _comparer = range.Comparer; } else { _includesStart = range.IncludesEnd; _includesEnd = range.IncludesStart; _start = range.Maximum; _end = range.Minimum; _comparer = range.Comparer.Reverse(); } }
public Range([NotNull] LambdaRange <T> range) : this(range.Minimum, range.Maximum) { }
public NumericRange([NotNull] LambdaRange <T> range) : base(range) { }
public DateRangeLister([NotNull] LambdaRange <DateTime> range, DateTimeUnit unit) : this(range.Minimum, range.Maximum, unit) { }
/// <inheritdoc /> /// <summary> /// Creates an ascending iterator over the given range with the given step function /// </summary> public LambdaRangeEnumerator([NotNull] LambdaRange <T> range, [NotNull] Func <T, T> step) : this(range, step, true) { }
public LambdaRange([NotNull] LambdaRange <T> range) : this(range.Minimum, range.Maximum, Comparer <T> .Default, true, true) { }
public static LambdaRangeEnumerator <char> StepChar([NotNull] this LambdaRange <char> range, int step) { return(range.Step(c => (char)(c + step))); }
public ReadOnlyRange([NotNull] LambdaRange <T> range) : this(new Range <T>(range.Minimum, range.Maximum)) { }