public IntervalTreePerfTest()
        {
            _ranges = Enumerable.Range(0, _count)
                      .ToCompositeRange(i => 4 * i - 2 * (i % 4), i => 1 + 4 * i + 2 * (i % 4), i => i.ToString());

            _intersection       = _ranges.SubRanges[1000].WithoutKey();
            _intersectionCostin = new Interval <int>(_intersection.FromValue, _intersection.ToValue);

            _tree       = new IntervalTree <int, string>(_ranges);
            _treeCostin = new IntervalTreeCostin <int, string>(
                _ranges.SubRanges.Select(r => new KeyValuePair <IInterval <int>, string>(
                                             new Interval <int>(r.FromValue, r.ToValue), r.Key))
                );
        }
        public static void TestRangesCore(CompositeRange <int, string> ranges)
        {
            var tree = new IntervalTree <int, string>(ranges);

            for (var i = ranges.ContainingRange.FromValue; i <= ranges.ContainingRange.ToValue; i++)
            {
                var overlapRange = Range.Create(i, i);
                AssertSameOverlap(ranges, tree, overlapRange);
                overlapRange = Range.Create(i - 1, i + 1);
                AssertSameOverlap(ranges, tree, overlapRange);
                overlapRange = Range.Create(i - 2, i + 2);
                AssertSameOverlap(ranges, tree, overlapRange);
                overlapRange = Range.Create(i - 10, i);
                AssertSameOverlap(ranges, tree, overlapRange);
            }
        }
 private static void AssertSameOverlap(CompositeRange <int, string> ranges, [NotNull] IntervalTree <int, string> tree, Range <int> overlapRange) =>
 Assert.AreEqual(
     ranges.SubRanges.Where(r => r.HasIntersection(overlapRange)).Join(";"),
     tree.Intersect(overlapRange).Join(";"));