예제 #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()));
 }
예제 #5
0
		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
			))
		{
		}
예제 #25
0
 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));
 }