示例#1
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);
		}
示例#2
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);
		}
示例#3
0
		public static IBTreeRange Intersect(BTreeRangeUnion union, BTreeRangeSingle single
			)
		{
			SortedCollection4 collection = NewBTreeRangeSingleCollection();
			CollectIntersections(collection, union, single);
			return ToRange(collection);
		}
示例#4
0
 public int Compare(object x, object y)
 {
     Db4objects.Db4o.Internal.Btree.BTreeRangeSingle xRange = (Db4objects.Db4o.Internal.Btree.BTreeRangeSingle
                                                               )x;
     Db4objects.Db4o.Internal.Btree.BTreeRangeSingle yRange = (Db4objects.Db4o.Internal.Btree.BTreeRangeSingle
                                                               )y;
     return(xRange.First().CompareTo(yRange.First()));
 }
		public AbstractBTreeRangeIterator(BTreeRangeSingle range)
		{
			_range = range;
			BTreePointer first = range.First();
			if (first != null)
			{
				// we clone here, because we are calling unsafeNext() on BTreePointer
				// _cursor is our private copy, we modify it and never pass it out.
				_cursor = first.ShallowClone();
			}
		}
        public AbstractBTreeRangeIterator(BTreeRangeSingle range)
        {
            _range = range;
            BTreePointer first = range.First();

            if (first != null)
            {
                // we clone here, because we are calling unsafeNext() on BTreePointer
                // _cursor is our private copy, we modify it and never pass it out.
                _cursor = first.ShallowClone();
            }
        }
示例#7
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));
				}
			}
		}
示例#8
0
 private Db4objects.Db4o.Internal.Btree.BTreeRangeSingle CheckRangeArgument(IBTreeRange
                                                                            range)
 {
     if (null == range)
     {
         throw new ArgumentNullException();
     }
     Db4objects.Db4o.Internal.Btree.BTreeRangeSingle rangeImpl = (Db4objects.Db4o.Internal.Btree.BTreeRangeSingle
                                                                  )range;
     if (Btree() != rangeImpl.Btree())
     {
         throw new ArgumentException();
     }
     return(rangeImpl);
 }
		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;
		}
示例#10
0
        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);
        }
示例#11
0
		public BTreeRangeSingleIntersect(BTreeRangeSingle single) : base(single)
		{
		}
示例#12
0
 public virtual bool Adjacent(BTreeRangeSingle range
     )
 {
     return BTreePointer.Equals(_end, range._first) || BTreePointer.Equals(range._end,
         _first);
 }
示例#13
0
 public virtual bool Overlaps(Db4objects.Db4o.Internal.Btree.BTreeRangeSingle range
                              )
 {
     return(FirstOverlaps(this, range) || FirstOverlaps(range, this));
 }
示例#14
0
		public void Visit(BTreeRangeSingle single)
		{
			_resultingRange = Execute(single);
		}
示例#15
0
 private bool FirstOverlaps(BTreeRangeSingle x, BTreeRangeSingle
                            y)
 {
     return(BTreePointer.LessThan(y._first, x._end) && BTreePointer.LessThan(x._first,
                                                                             y._end));
 }
		public BTreeRangePointerIterator(BTreeRangeSingle range) : base(range)
		{
		}
示例#17
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 });
		}
示例#18
0
 public BTreeRangeKeyIterator(BTreeRangeSingle range) : base(range)
 {
 }
示例#19
0
 private bool FirstOverlaps(BTreeRangeSingle x, BTreeRangeSingle
     y)
 {
     return BTreePointer.LessThan(y._first, x._end) && BTreePointer.LessThan(x._first,
         y._end);
 }
示例#20
0
 public virtual IBTreeRange ExtendToLastOf(IBTreeRange range)
 {
     Db4objects.Db4o.Internal.Btree.BTreeRangeSingle rangeImpl = CheckRangeArgument(range
                                                                                    );
     return(NewBTreeRangeSingle(_first, rangeImpl._end));
 }
示例#21
0
 private bool FirstOverlaps(Db4objects.Db4o.Internal.Btree.BTreeRangeSingle x, Db4objects.Db4o.Internal.Btree.BTreeRangeSingle
                            y)
 {
     return(BTreePointer.LessThan(y._first, x._end) && BTreePointer.LessThan(x._first,
                                                                             y._end));
 }
示例#22
0
 public AbstractBTreeRangeIterator(BTreeRangeSingle range)
 {
     _range = range;
     _cursor = range.First();
 }
		public BTreeRangeSingleUnion(BTreeRangeSingle single) : base(single)
		{
		}
		public BTreeRangeUnion(BTreeRangeSingle[] ranges) : this(ToSortedCollection(ranges
			))
		{
		}
 public BTreeRangePointerIterator(BTreeRangeSingle range) : base(range)
 {
 }
示例#26
0
 public AbstractBTreeRangeIterator(BTreeRangeSingle range)
 {
     _range  = range;
     _cursor = range.First();
 }
示例#27
0
 public virtual bool Overlaps(BTreeRangeSingle range
                              )
 {
     return(FirstOverlaps(this, range) || FirstOverlaps(range, this));
 }
示例#28
0
		protected override IBTreeRange Execute(BTreeRangeSingle range)
		{
			return BTreeAlgebra.Intersect(_union, range);
		}
示例#29
0
 public virtual bool Overlaps(BTreeRangeSingle range
     )
 {
     return FirstOverlaps(this, range) || FirstOverlaps(range, this);
 }
示例#30
0
		protected abstract IBTreeRange Execute(BTreeRangeSingle single);
示例#31
0
 public virtual bool Adjacent(Db4objects.Db4o.Internal.Btree.BTreeRangeSingle range
                              )
 {
     return(BTreePointer.Equals(_end, range._first) || BTreePointer.Equals(range._end,
                                                                           _first));
 }
		public BTreeRangeKeyIterator(BTreeRangeSingle range) : base(range)
		{
		}
示例#33
0
		private static BTreeRangeSingle Merge(BTreeRangeSingle range1, BTreeRangeSingle range2
			)
		{
			return range1.NewBTreeRangeSingle(BTreePointer.Min(range1.First(), range2.First()
				), BTreePointer.Max(range1.End(), range2.End()));
		}
		protected override IBTreeRange Execute(BTreeRangeSingle single)
		{
			return BTreeAlgebra.Union(_single, single);
		}
示例#35
0
		private static bool CanBeMerged(BTreeRangeSingle range1, BTreeRangeSingle range2)
		{
			return range1.Overlaps(range2) || range1.Adjacent(range2);
		}
示例#36
0
		public BTreeRangeSingleOperation(BTreeRangeSingle single)
		{
			_single = single;
		}
示例#37
0
 public virtual bool Adjacent(BTreeRangeSingle range
                              )
 {
     return(BTreePointer.Equals(_end, range._first) || BTreePointer.Equals(range._end,
                                                                           _first));
 }