public BTreeRangeUnion(SortedCollection4 sorted) { if (null == sorted) { throw new ArgumentNullException(); } _ranges = ToArray(sorted); }
private static void CollectIntersections(SortedCollection4 collection, BTreeRangeUnion union, BTreeRangeSingle single) { IEnumerator ranges = union.Ranges(); while (ranges.MoveNext()) { BTreeRangeSingle current = (BTreeRangeSingle)ranges.Current; if (single.Overlaps(current)) { collection.Add(single.Intersect(current)); } } }
private static SortedCollection4 ToSortedCollection(BTreeRangeSingle[] ranges) { if (null == ranges) { throw new ArgumentNullException(); } SortedCollection4 collection = new SortedCollection4(BTreeRangeSingle.Comparison); for (int i = 0; i < ranges.Length; i++) { BTreeRangeSingle range = ranges[i]; if (!range.IsEmpty()) { collection.Add(range); } } return collection; }
private void AssertCollection(int[] expected, SortedCollection4 collection) { Assert.AreEqual(expected.Length, collection.Size()); ArrayAssert.AreEqual(IntArrays4.ToObjectArray(expected), collection.ToArray(new object [collection.Size()])); }
private static BTreeRangeSingle[] ToArray(SortedCollection4 collection) { return (BTreeRangeSingle[])collection.ToArray(new BTreeRangeSingle[collection.Size ()]); }
private static IBTreeRange ToRange(SortedCollection4 sorted) { if (1 == sorted.Size()) { return (IBTreeRange)sorted.SingleElement(); } return new BTreeRangeUnion(sorted); }