示例#1
0
        public static bool TryParse(ReadOnlySpan <char> input, out CompositeInterval <T> interval)
        {
            var result = CompositeInterval <T, DefaultValueComparer <T> > .TryParse(input, out var comparerInterval);

            interval = comparerInterval;
            return(result);
        }
示例#2
0
        public static bool TryParse(string input, TryParse <T> elementParser, out CompositeInterval <T> interval)
        {
            var result = CompositeInterval <T, DefaultValueComparer <T> > .TryParse(input, elementParser, out var comparerInterval);

            interval = comparerInterval;
            return(result);
        }
        public static bool TryParse(string input, out CompositeInterval <T, TComparer> interval)
        {
            if (input is null)
            {
                Throw.ArgumentNullException(nameof(input));
            }

            return(Parser.TryParseCompositeInterval(input, ElementParsers.GetTryElementParser <T>(), out interval));
        }
        public static bool TryParse(string input, TryParse <T> elementParser, out CompositeInterval <T, TComparer> interval)
        {
            if (input is null)
            {
                Throw.ArgumentNullException(nameof(input));
            }
            if (elementParser is null)
            {
                Throw.ArgumentNullException(nameof(elementParser));
            }

            throw new NotImplementedException();
            //return Parser.TryParseCompositeInterval(input, elementParser, out interval);
        }
        internal static R CompositeIntervalLength <T, R>(CompositeInterval <T> interval) where T : IComparable <T>
        {
            throw new NotImplementedException("Generic length cannot inferred! This has to be worked around somehow.");

            /*
             * var intervals = interval.CompositeIntervals;
             * var length = GenericSpecializer<R>.ZeroValueOfThisType;
             *
             * for (int i = 0; i < intervals.Count; i++)
             * {
             *  length = Add(length, IntervalLength<T, R>(intervals[i]));
             * }
             *
             * return length;
             */
        }
 /// <summary>
 /// Computes the length of this interval: sum of the lengths of the continuous intervals it represents.
 /// </summary>
 /// <exception cref="ArgumentNullException" />
 public static R Length <T, R>(this CompositeInterval <T> interval) where T : ISubtractable <T, R> where R : IAddable <R> => CompositeIntervalLength <T, R>(interval);
 /// <summary>
 /// Computes the length of this interval: sum of the lengths of the continuous intervals it represents.
 /// </summary>
 /// <exception cref="ArgumentNullException" />
 public static int Length(this CompositeInterval <byte> interval) => CompositeIntervalLength <byte, int>(interval);
 /// <summary>
 /// Returns a new composite interval that contains all values on the number line not present in this interval.
 /// </summary>
 public static CompositeInterval <float> Complement(this CompositeInterval <float> interval) => interval.SymmetricDifference(NumberLineOfSingles);
 /// <summary>
 /// Returns a new composite interval that contains all possible <see cref="decimal"/> values not present in this interval.
 /// </summary>
 public static CompositeInterval <decimal> Complement(this CompositeInterval <decimal> interval) => interval.SymmetricDifference(AllDecimals);
 /// <summary>
 /// Returns a new composite interval that contains all possible <see cref="sbyte"/> values not present in this interval.
 /// </summary>
 public static CompositeInterval <sbyte> Complement(this CompositeInterval <sbyte> interval) => interval.SymmetricDifference(AllSBytes);
 /// <summary>
 /// Computes the length of this interval: sum of the lengths of the continuous intervals it represents.
 /// </summary>
 /// <exception cref="ArgumentNullException" />
 public static int Length(this CompositeInterval <ushort> interval) => CompositeIntervalLength <ushort, int>(interval);
 public static bool TryParse(ReadOnlySpan <char> input, out CompositeInterval <T, TComparer> interval) => Parser.TryParseCompositeInterval(input, ElementParsers.GetTrySpanElementParser <T>(), out interval);
 /// <summary>
 /// Computes the length of this interval: sum of the lengths of the continuous intervals it represents.
 /// </summary>
 /// <exception cref="ArgumentNullException" />
 public static decimal Length <T>(this CompositeInterval <T> interval) where T : ISubtractable <T, decimal> => Lengths.CompositeIntervalLength <T, decimal>(interval);
 /// <summary>
 /// Computes the length of this interval: sum of the lengths of the continuous intervals it represents.
 /// </summary>
 /// <exception cref="ArgumentNullException" />
 public static long Length(this CompositeInterval <uint> interval) => CompositeIntervalLength <uint, long>(interval);
 /// <summary>
 /// Computes the length of this interval: sum of the lengths of the continuous intervals it represents.
 /// </summary>
 /// <exception cref="ArgumentNullException" />
 public static float Length <T>(this CompositeInterval <T> interval) where T : ISubtractable <T, float> => Lengths.CompositeIntervalLength <T, float>(interval);
 /// <summary>
 /// Computes the length of this interval: sum of the lengths of the continuous intervals it represents.
 /// </summary>
 /// <exception cref="ArgumentNullException" />
 public static ulong Length <T>(this CompositeInterval <T> interval) where T : ISubtractable <T, ulong> => Lengths.CompositeIntervalLength <T, ulong>(interval);
 /// <summary>
 /// Computes the length of this interval: sum of the lengths of the continuous intervals it represents.
 /// </summary>
 /// <exception cref="ArgumentNullException" />
 public static byte Length <T>(this CompositeInterval <T> interval) where T : ISubtractable <T, byte> => Lengths.CompositeIntervalLength <T, byte>(interval);
        public static bool TryParse(ReadOnlySpan <char> input, TryParseSpan <T> elementParser, out CompositeInterval <T, TComparer> interval)
        {
            if (elementParser is null)
            {
                Throw.ArgumentNullException(nameof(elementParser));
            }

            return(Parser.TryParseCompositeInterval(input, elementParser, out interval));
        }
 /// <summary>
 /// Computes the length of this interval: sum of the lengths of the continuous intervals it represents.
 /// </summary>
 /// <exception cref="ArgumentNullException" />
 public static TimeSpan Length <T>(this CompositeInterval <T> interval) where T : ISubtractable <T, TimeSpan> => Lengths.CompositeIntervalLength <T, TimeSpan>(interval);
 /// <summary>
 /// Returns a new composite interval that contains all possible <see cref="short"/> values not present in this interval.
 /// </summary>
 public static CompositeInterval <short> Complement(this CompositeInterval <short> interval) => interval.SymmetricDifference(AllInt16s);
 /// <summary>
 /// Returns a new composite interval that contains all possible <see cref="ulong"/> values not present in this interval.
 /// </summary>
 public static CompositeInterval <ulong> Complement(this CompositeInterval <ulong> interval) => interval.SymmetricDifference(AllUInt64s);
 /// <summary>
 /// Computes the length of this interval: sum of the lengths of the continuous intervals it represents.
 /// </summary>
 /// <exception cref="ArgumentNullException" />
 public static ulong Length(this CompositeInterval <ulong> interval) => CompositeIntervalLength <ulong, ulong>(interval);
 /// <summary>
 /// Returns a new composite interval that contains all possible <see cref="DateTimeOffset"/> values not present in this interval.
 /// </summary>
 public static CompositeInterval <DateTimeOffset> Complement(this CompositeInterval <DateTimeOffset> interval) => interval.SymmetricDifference(AllDateTimeOffsets);
 /// <summary>
 /// Computes the length of this interval: sum of the lengths of the continuous intervals it represents.
 /// </summary>
 /// <exception cref="ArgumentNullException" />
 public static float Length(this CompositeInterval <float> interval) => CompositeIntervalLength <float, float>(interval);
 /// <summary>
 /// Returns a new composite interval that contains all possible <see cref="Char"/> values not present in this interval.
 /// </summary>
 public static CompositeInterval <char> Complement(this CompositeInterval <char> interval) => interval.SymmetricDifference(AllChars);
 /// <summary>
 /// Computes the length of this interval: sum of the lengths of the continuous intervals it represents.
 /// </summary>
 /// <exception cref="ArgumentNullException" />
 public static double Length(this CompositeInterval <double> interval) => CompositeIntervalLength <double, double>(interval);
 /// <summary>
 /// Returns a new composite interval that contains all values on the number line not present in this interval.
 /// </summary>
 public static CompositeInterval <double> Complement(this CompositeInterval <double> interval) => interval.SymmetricDifference(NumberLineOfDoubles);
 /// <summary>
 /// Computes the length of this interval: sum of the lengths of the continuous intervals it represents. May overflow!
 /// </summary>
 /// <exception cref="ArgumentNullException" />
 /// <exception cref="OverflowException" />
 public static decimal Length(this CompositeInterval <decimal> interval) => CompositeIntervalLength <decimal, decimal>(interval);
 /// <summary>
 /// Returns a new composite interval that contains all possible <see cref="uint"/> values not present in this interval.
 /// </summary>
 public static CompositeInterval <uint> Complement(this CompositeInterval <uint> interval) => interval.SymmetricDifference(AllUInt32s);
 /// <summary>
 /// Computes the length of this interval: sum of the lengths of the continuous intervals it represents.
 /// </summary>
 /// <exception cref="ArgumentNullException" />
 public static TimeSpan Length(this CompositeInterval <DateTimeOffset> interval) => CompositeIntervalLength <DateTimeOffset, TimeSpan>(interval);