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); }
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 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(); } }
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)); } } }
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; }
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); }
public BTreeRangeSingleIntersect(BTreeRangeSingle single) : base(single) { }
public virtual bool Adjacent(BTreeRangeSingle range ) { return BTreePointer.Equals(_end, range._first) || BTreePointer.Equals(range._end, _first); }
public virtual bool Overlaps(Db4objects.Db4o.Internal.Btree.BTreeRangeSingle range ) { return(FirstOverlaps(this, range) || FirstOverlaps(range, this)); }
public void Visit(BTreeRangeSingle single) { _resultingRange = Execute(single); }
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) { }
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 }); }
public BTreeRangeKeyIterator(BTreeRangeSingle range) : base(range) { }
private bool FirstOverlaps(BTreeRangeSingle x, BTreeRangeSingle y) { return BTreePointer.LessThan(y._first, x._end) && BTreePointer.LessThan(x._first, y._end); }
public virtual IBTreeRange ExtendToLastOf(IBTreeRange range) { Db4objects.Db4o.Internal.Btree.BTreeRangeSingle rangeImpl = CheckRangeArgument(range ); return(NewBTreeRangeSingle(_first, rangeImpl._end)); }
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)); }
public AbstractBTreeRangeIterator(BTreeRangeSingle range) { _range = range; _cursor = range.First(); }
public BTreeRangeSingleUnion(BTreeRangeSingle single) : base(single) { }
public BTreeRangeUnion(BTreeRangeSingle[] ranges) : this(ToSortedCollection(ranges )) { }
public virtual bool Overlaps(BTreeRangeSingle range ) { return(FirstOverlaps(this, range) || FirstOverlaps(range, this)); }
protected override IBTreeRange Execute(BTreeRangeSingle range) { return BTreeAlgebra.Intersect(_union, range); }
public virtual bool Overlaps(BTreeRangeSingle range ) { return FirstOverlaps(this, range) || FirstOverlaps(range, this); }
protected abstract IBTreeRange Execute(BTreeRangeSingle single);
public virtual bool Adjacent(Db4objects.Db4o.Internal.Btree.BTreeRangeSingle range ) { return(BTreePointer.Equals(_end, range._first) || BTreePointer.Equals(range._end, _first)); }
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); }
private static bool CanBeMerged(BTreeRangeSingle range1, BTreeRangeSingle range2) { return range1.Overlaps(range2) || range1.Adjacent(range2); }
public BTreeRangeSingleOperation(BTreeRangeSingle single) { _single = single; }
public virtual bool Adjacent(BTreeRangeSingle range ) { return(BTreePointer.Equals(_end, range._first) || BTreePointer.Equals(range._end, _first)); }