Esempio n. 1
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));
        }
Esempio n. 2
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);
 }
Esempio n. 3
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 }));
 }
Esempio n. 4
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});
 }