public static IBTreeRange Union(BTreeRangeUnion union, BTreeRangeSingle single) { if (single.IsEmpty()) { return union; } SortedCollection4 sorted = NewBTreeRangeSingleCollection(); sorted.Add(single); BTreeRangeSingle range = single; IEnumerator ranges = union.Ranges(); while (ranges.MoveNext()) { BTreeRangeSingle current = (BTreeRangeSingle)ranges.Current; if (CanBeMerged(current, range)) { sorted.Remove(range); range = Merge(current, range); sorted.Add(range); } else { sorted.Add(current); } } return ToRange(sorted); }
public static IBTreeRange Intersect(BTreeRangeUnion union, BTreeRangeSingle single ) { SortedCollection4 collection = NewBTreeRangeSingleCollection(); CollectIntersections(collection, union, single); return ToRange(collection); }
public static IBTreeRange Union(BTreeRangeUnion union1, BTreeRangeUnion union2) { IEnumerator ranges = union1.Ranges(); IBTreeRange merged = union2; while (ranges.MoveNext()) { merged = merged.Union((IBTreeRange)ranges.Current); } return merged; }
public static IBTreeRange Intersect(BTreeRangeUnion union1, BTreeRangeUnion union2 ) { SortedCollection4 collection = NewBTreeRangeSingleCollection(); IEnumerator ranges = union1.Ranges(); while (ranges.MoveNext()) { BTreeRangeSingle current = (BTreeRangeSingle)ranges.Current; CollectIntersections(collection, union2, current); } return ToRange(collection); }
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)); } } }
public BTreeRangeUnionOperation(BTreeRangeUnion union) { _union = union; }
protected override IBTreeRange Execute(BTreeRangeUnion union) { return BTreeAlgebra.Union(union, _single); }
protected abstract IBTreeRange Execute(BTreeRangeUnion union);
public void Visit(BTreeRangeUnion union) { _resultingRange = Execute(union); }
protected override IBTreeRange Execute(BTreeRangeUnion union) { return BTreeAlgebra.Intersect(_union, union); }
public BTreeRangeUnionIntersect(BTreeRangeUnion union) : base(union) { }
public BTreeRangeUnionUnion(BTreeRangeUnion union) : base(union) { }