Exemplo n.º 1
0
 public static IBTreeRange Intersect(BTreeRangeSingle single1, BTreeRangeSingle single2
     )
 {
     var first = BTreePointer.Max(single1.First(), single2.First());
     var end = BTreePointer.Min(single1.End(), single2.End());
     return single1.NewBTreeRangeSingle(first, end);
 }
Exemplo n.º 2
0
 public static IBTreeRange Intersect(BTreeRangeUnion union, BTreeRangeSingle single
     )
 {
     var collection = NewBTreeRangeSingleCollection();
     CollectIntersections(collection, union, single);
     return ToRange(collection);
 }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
 public static IBTreeRange Union(BTreeRangeUnion union, BTreeRangeSingle single)
 {
     if (single.IsEmpty())
     {
         return union;
     }
     var sorted = NewBTreeRangeSingleCollection();
     sorted.Add(single);
     var range = single;
     var ranges = union.Ranges();
     while (ranges.MoveNext())
     {
         var 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);
 }
Exemplo n.º 5
0
        public static IBTreeRange Intersect(BTreeRangeSingle single1, BTreeRangeSingle single2
                                            )
        {
            BTreePointer first = BTreePointer.Max(single1.First(), single2.First());
            BTreePointer end   = BTreePointer.Min(single1.End(), single2.End());

            return(single1.NewBTreeRangeSingle(first, end));
        }
Exemplo n.º 6
0
        public static IBTreeRange Intersect(BTreeRangeUnion union, BTreeRangeSingle single
                                            )
        {
            SortedCollection4 collection = NewBTreeRangeSingleCollection();

            CollectIntersections(collection, union, single);
            return(ToRange(collection));
        }
Exemplo n.º 7
0
 private static void CollectIntersections(SortedCollection4 collection, BTreeRangeUnion
     union, BTreeRangeSingle single)
 {
     var ranges = union.Ranges();
     while (ranges.MoveNext())
     {
         var current = (BTreeRangeSingle) ranges.Current;
         if (single.Overlaps(current))
         {
             collection.Add(single.Intersect(current));
         }
     }
 }
Exemplo n.º 8
0
        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));
        }
Exemplo n.º 9
0
        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));
                }
            }
        }
Exemplo n.º 10
0
 public static IBTreeRange Union(BTreeRangeSingle single1, BTreeRangeSingle single2
                                 )
 {
     if (single1.IsEmpty())
     {
         return(single2);
     }
     if (single2.IsEmpty())
     {
         return(single1);
     }
     if (CanBeMerged(single1, single2))
     {
         return(Merge(single1, single2));
     }
     return(new BTreeRangeUnion(new BTreeRangeSingle[] { single1, single2 }));
 }
Exemplo n.º 11
0
 private static BTreeRangeSingle Merge(BTreeRangeSingle range1, BTreeRangeSingle range2
                                       )
 {
     return(range1.NewBTreeRangeSingle(BTreePointer.Min(range1.First(), range2.First()
                                                        ), BTreePointer.Max(range1.End(), range2.End())));
 }
Exemplo n.º 12
0
 public BTreeRangeSingleIntersect(BTreeRangeSingle single) : base(single)
 {
 }
Exemplo n.º 13
0
 protected override IBTreeRange Execute(BTreeRangeSingle range)
 {
     return BTreeAlgebra.Intersect(_union, range);
 }
Exemplo n.º 14
0
 public static IBTreeRange Union(BTreeRangeSingle single1, BTreeRangeSingle single2
     )
 {
     if (single1.IsEmpty())
     {
         return single2;
     }
     if (single2.IsEmpty())
     {
         return single1;
     }
     if (CanBeMerged(single1, single2))
     {
         return Merge(single1, single2);
     }
     return new BTreeRangeUnion(new[] {single1, single2});
 }
Exemplo n.º 15
0
 protected override IBTreeRange Execute(BTreeRangeSingle single)
 {
     return BTreeAlgebra.Union(_single, single);
 }
Exemplo n.º 16
0
 public BTreeRangeSingleOperation(BTreeRangeSingle single)
 {
     _single = single;
 }
Exemplo n.º 17
0
 public void Visit(BTreeRangeSingle single)
 {
     _resultingRange = Execute(single);
 }
Exemplo n.º 18
0
 protected abstract IBTreeRange Execute(BTreeRangeSingle single);
Exemplo n.º 19
0
 private static bool CanBeMerged(BTreeRangeSingle range1, BTreeRangeSingle range2)
 {
     return range1.Overlaps(range2) || range1.Adjacent(range2);
 }
Exemplo n.º 20
0
 private static BTreeRangeSingle Merge(BTreeRangeSingle range1, BTreeRangeSingle range2
     )
 {
     return range1.NewBTreeRangeSingle(BTreePointer.Min(range1.First(), range2.First()
         ), BTreePointer.Max(range1.End(), range2.End()));
 }
Exemplo n.º 21
0
 private static bool CanBeMerged(BTreeRangeSingle range1, BTreeRangeSingle range2)
 {
     return(range1.Overlaps(range2) || range1.Adjacent(range2));
 }
Exemplo n.º 22
0
 public void Visit(BTreeRangeSingle single)
 {
     _resultingRange = Execute(single);
 }
Exemplo n.º 23
0
 public BTreeRangeSingleUnion(BTreeRangeSingle single) : base(single)
 {
 }
Exemplo n.º 24
0
 public BTreeRangeKeyIterator(BTreeRangeSingle range) : base(range)
 {
 }
Exemplo n.º 25
0
 public BTreeRangeSingleOperation(BTreeRangeSingle single)
 {
     _single = single;
 }
Exemplo n.º 26
0
 public BTreeRangeSingleUnion(BTreeRangeSingle single) : base(single)
 {
 }
Exemplo n.º 27
0
 public BTreeRangePointerIterator(BTreeRangeSingle range) : base(range)
 {
 }
Exemplo n.º 28
0
 public BTreeRangeKeyIterator(BTreeRangeSingle range) : base(range)
 {
 }
Exemplo n.º 29
0
 public BTreeRangeSingleIntersect(BTreeRangeSingle single) : base(single)
 {
 }
Exemplo n.º 30
0
 protected abstract IBTreeRange Execute(BTreeRangeSingle single);
Exemplo n.º 31
0
 protected override IBTreeRange Execute(BTreeRangeSingle range)
 {
     return(BTreeAlgebra.Intersect(_union, range));
 }
Exemplo n.º 32
0
 protected override IBTreeRange Execute(BTreeRangeSingle single)
 {
     return(BTreeAlgebra.Union(_single, single));
 }
Exemplo n.º 33
0
 public BTreeRangePointerIterator(BTreeRangeSingle range) : base(range)
 {
 }