/// <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();
            }
        }
Esempio n. 2
0
 public Range([NotNull] LambdaRange <T> range)
     : this(range.Minimum, range.Maximum)
 {
 }
Esempio n. 3
0
 public NumericRange([NotNull] LambdaRange <T> range)
     : base(range)
 {
 }
Esempio n. 4
0
 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)
 {
 }
Esempio n. 6
0
 public LambdaRange([NotNull] LambdaRange <T> range)
     : this(range.Minimum, range.Maximum, Comparer <T> .Default, true, true)
 {
 }
Esempio n. 7
0
 public static LambdaRangeEnumerator <char> StepChar([NotNull] this LambdaRange <char> range, int step)
 {
     return(range.Step(c => (char)(c + step)));
 }
Esempio n. 8
0
 public ReadOnlyRange([NotNull] LambdaRange <T> range)
     : this(new Range <T>(range.Minimum, range.Maximum))
 {
 }