示例#1
0
            public RangeAlternativesIntCase()
            {
                _data             = new KeyValuePair <int, int> [Count];
                _rangeData        = new RangeStub <int> [Count];
                _rangeKeyData     = new RangeStub <int, string> [Count];
                _rangeCompactData = new RangeStubCompact <int> [Count];
                _rangeDataImpl    = new Range <int> [Count];
                _rangeKeyDataImpl = new Range <int, string> [Count];

                for (var i = 0; i < _data.Length; i++)
                {
                    _data[i]             = new KeyValuePair <int, int>(i, i + 1);
                    _rangeData[i]        = new RangeStub <int>(i, i + 1);
                    _rangeKeyData[i]     = new RangeStub <int, string>(i, i + 1, i.ToString());
                    _rangeCompactData[i] = new RangeStubCompact <int>(i, i + 1);
                    _rangeDataImpl[i]    = new Range <int>(i, i + 1);
                    _rangeKeyDataImpl[i] = new Range <int, string>(i, i + 1, i.ToString());
                }
            }
            public RangeUnionIntCase()
            {
                _data           = new KeyValuePair <int, int> [Count];
                _data2          = new KeyValuePair <int, int> [Count];
                _rangeData      = new RangeStub <int> [Count];
                _rangeData2     = new RangeStub <int> [Count];
                _rangeDataImpl  = new Range <int> [Count];
                _rangeDataImpl2 = new Range <int> [Count];

                for (var i = 0; i < _data.Length; i++)
                {
                    var fromBoundary = i % 7 == 0 ? RangeBoundaryFrom <int> .NegativeInfinity : Range.BoundaryFrom(i);
                    var toBoundary   = i % 5 == 0 ? RangeBoundaryTo <int> .PositiveInfinity : Range.BoundaryTo(i);
                    _data[i]           = new KeyValuePair <int, int>(i, i + 1);
                    _data2[i]          = new KeyValuePair <int, int>(i - 1, i);
                    _rangeData[i]      = new RangeStub <int>(fromBoundary, Range.BoundaryTo(i + 1));
                    _rangeData2[i]     = new RangeStub <int>(Range.BoundaryFrom(i - 1), toBoundary);
                    _rangeDataImpl[i]  = new Range <int>(fromBoundary, Range.BoundaryTo(i + 1));
                    _rangeDataImpl2[i] = new Range <int>(Range.BoundaryFrom(i - 1), toBoundary);
                }
            }
 public RangeStub <T> UnionInstance(RangeStub <T> other) => new RangeStub <T>(
     _from <= other._from ? _from : other._from,
     (_to.IsEmpty || _to >= other._to) ? _to : other._to);
 public static RangeStub <T, TKey> Union <T, TKey>(this RangeStub <T, TKey> range, RangeStub <T, TKey> other) =>
 range.CreateRange(
     range.From <= other.From ? range.From : other.From,
     (range.To.IsEmpty || range.To >= other.To) ? range.To : other.To);
示例#5
0
 public static RangeStub <T, TKey> Union <T, TKey, TRange>(this RangeStub <T, TKey> range1, TRange range2)
     where TRange : IRange <T> =>
 UnionCore <RangeStub <T, TKey>, TRange, T>(range1, range2);
示例#6
0
 public static TRange UnionAlt <T, TRange>(this TRange range, RangeStub <T> other)
     where TRange : IRangeFactory <T, TRange> =>
 range.CreateRange(
     range.From <= other.From ? range.From : other.From,
     (range.To.IsEmpty || range.To >= other.To) ? range.To : other.To);