/*
(non-Javadoc)
@see net.ossindex.version.IVersionRange#intersects(net.ossindex.version.IVersionRange)
18557
@Override
  public boolean intersects(IVersionRange yourRange)
  {
    return range1.intersects(yourRange) && range2.intersects(yourRange);
  }
955462
def intersect(self,range2):
    
    if not self.overlaps(range2): return None
    return type(self)(self.chr,max(self.start,range2.start)+self._start_offset,min(self.end,range2.end),self.payload,self.dir)
468702
public Bbox intersection(Bbox other) {
		if (!this.intersects(other)) {
			return null;
		} else {
			double minx = other.getX() > this.getX() ? other.getX() : this.getX();
			double maxx = other.getEndPoint().getX() < this.getEndPoint().getX() ? other.getEndPoint().getX() : this
					.getEndPoint().getX();
			double miny = other.getY() > this.getY() ? other.getY() : this.getY();
			double maxy = other.getEndPoint().getY() < this.getEndPoint().getY() ? other.getEndPoint().getY() : this
					.getEndPoint().getY();
			return new Bbox(minx, miny, (maxx - minx), (maxy - miny));
		}
	}
595506
public static <T extends Comparable<T>> RangeSet<T> intersectRangeSets(final Iterable<RangeSet<T>> rangeSets)
  {
    RangeSet<T> rangeSet = null;
    for (final RangeSet<T> set : rangeSets) {
      if (rangeSet == null) {
        rangeSet = TreeRangeSet.create();
        rangeSet.addAll(set);
      } else {
        rangeSet.removeAll(set.complement());
      }
    }
    return rangeSet;
  }
384543
public boolean intersects(long minimum, long supremum) {
    rangeSanityCheck(minimum, supremum);
    short minKey = Util.highbits(minimum);
    short supKey = Util.highbits(supremum);
    int len = highLowContainer.size;
    short[] keys = highLowContainer.keys;
    // seek to start
    int index = Util.unsignedBinarySearch(keys, 0, len, minKey);
    int pos = index >= 0 ? index : -index - 1;
    short offset = Util.lowbits(minimum);
    while (pos < len && Util.compareUnsigned(supKey, keys[pos]) > 0) {
      Container container = highLowContainer.getContainerAtIndex(pos);
      if (container.intersects(offset, 1 << 16)) {
        return true;
      }
      offset = 0;
      ++pos;
    }
    return pos < len
            && supKey == keys[pos]
            && highLowContainer.getContainerAtIndex(pos)
                               .intersects(0, (int)((supremum - 1) & 0xFFFF) + 1);
  }
283929
public static int intersectShape (IShape s, float x, float y, float w, float h) {
        if (!s.bounds().intersects(x, y, w, h)) {
            return 0;
        }
        return intersectPath(s.pathIterator(null), x, y, w, h);
    }
692887
public RangeInteger intersect(RangeInteger r) {
		if (min > r.max) return null;
		if (max < r.min) return null;
		return new RangeInteger(Math.max(min, r.min), Math.min(max, r.max));
	}
1097363
public boolean intersects(MappeableContainer x) {
    if (x instanceof MappeableArrayContainer) {
      return intersects((MappeableArrayContainer) x);
    } else if (x instanceof MappeableBitmapContainer) {
      return intersects((MappeableBitmapContainer) x);
    }
    return intersects((MappeableRunContainer) x);
  }
463311
protected boolean intersectsVertically(CmsPositionBean p1, CmsPositionBean p2) {

        return intersectIntervals(p1.getTop(), p1.getTop() + HEIGHT, p2.getTop(), p2.getTop() + HEIGHT);
    }
91457
@Override
	@Pure
	public boolean intersects(Shape2D<?, ?, ?, ?, ?, ? extends Rectangle2afp<?, ?, ?, ?, ?, ?>> rectangle) {
		if (boundsIntersects(rectangle)) {
			for (final PointGroup grp : groups()) {
				for (final Point2d pts : grp) {
					if (rectangle.contains(pts)) {
						return true;
					}
				}
			}
		}
		return false;
	}
849299
public final boolean intersects(final DateRange range) {
        boolean intersects = false;
        // Test for our start date in period
        // (Exclude if it is the end date of test range)
        if (range.includes(rangeStart) && !range.getRangeEnd().equals(rangeStart)) {
            intersects = true;
        }
        // Test for test range's start date in our range
        // (Exclude if it is the end date of our range)
        else if (includes(range.getRangeStart())
                && !rangeEnd.equals(range.getRangeStart())) {
            intersects = true;
        }
        return intersects;
    }
508337
public static NumericalValue intersect (final NumericalValue a, final NumericalValue b) {
        // early exit
        if (a == null || b == null) return null;
        // get ranges of a and b
        int aMin, aMax, bMin, bMax;
        if (a instanceof SingleNumericalValue) {
            final SingleNumericalValue v = (SingleNumericalValue) a;
            aMin = v.getValue();
            aMax = aMin;
        } else {
            final NumericalValueRange r = (NumericalValueRange) a;
            aMin = r.getMin();
            aMax = r.getMax();
        }
        if (b instanceof SingleNumericalValue) {
            final SingleNumericalValue v = (SingleNumericalValue) b;
            bMin = v.getValue();
            bMax = bMin;
        } else {
            final NumericalValueRange r = (NumericalValueRange) b;
            bMin = r.getMin();
            bMax = r.getMax();
        }
        // intersect ranges
        final int min = Math.max(aMin, bMin);
        final int max = Math.min(aMax, bMax);
        if (min == max)
            return SingleNumericalValue.create(min);
        else
            return NumericalValueRange.create(min, max);
    }
59655
public boolean intersects(Geometry geometry) {
		if (isEmpty()) {
			return false;
		}
		for (Point point : points) {
			if (point.intersects(geometry)) {
				return true;
			}
		}
		return false;
	}
633064
public boolean intersectsWith(Range other) {
        return !other.isEmpty() && !this.isEmpty() &&
                (this.contains(other.lower) || other.contains(this.lower)
                        || (other.upper > upper && other.lower < lower));
    }
561712
@Override
	@Pure
	public boolean intersects(Shape2D<?, ?, ?, ?, ?, ? extends Rectangle2afp<?, ?, ?, ?, ?, ?>> rectangle) {
		if (boundsIntersects(rectangle)) {
			final double x = getX();
			final double y = getY();
			final Rectangle2afp<?, ?, ?, ?, ?, ?> box = rectangle.toBoundingBox();
			final double minx = box.getMinX();
			final double miny = box.getMinY();
			final double maxx = box.getMaxX();
			final double maxy = box.getMaxY();

			return MathUtil.min(
					Segment2afp.calculatesDistanceSegmentPoint(minx, miny, maxx, miny, x, y),
					Segment2afp.calculatesDistanceSegmentPoint(minx, miny, minx, maxy, x, y),
					Segment2afp.calculatesDistanceSegmentPoint(maxx, miny, maxx, maxy, x, y),
					Segment2afp.calculatesDistanceSegmentPoint(minx, maxy, maxx, maxy, x, y)) <= this.radius;
		}
		return false;
	}
1061419
@Override
    public boolean overlaps(Range<T> other) {
        dbc.precondition(other != null, "checking for overlaps between a DenseRange<T> and null");
        if (other instanceof DenseRange == false) {
            return other.overlaps(this);
        }
        return !Order.of(comparator, Optional.of(this.begin()), other.end()).isGte() && !Order.of(comparator, Optional.of(other.begin()), this.end()).isGte();
    }
1169460
@Override
  public boolean intersects(IVersionRange yourRange)
  {
    // If the supplied set is a version set, let it deal with it
    if (yourRange instanceof VersionSet) {
      return yourRange.intersects(this);
    }
    // If the other range is a simple range, then we can just check the extremities
    // to see if they overlap
    else if (yourRange instanceof VersionRange) {
      IVersion useMyVersion = null;
      switch (operator) {
        case ">":
          useMyVersion = version.getNextVersion();
          break;
        case "<":
          useMyVersion = version.getPrevVersion();
          break;
        default:
          useMyVersion = version;
          break;
      }
      if (yourRange.contains(useMyVersion)) {
        return true;
      }

      IVersion useYourVersion = null;
      switch (((VersionRange) yourRange).operator) {
        case ">":
          useYourVersion = ((VersionRange) yourRange).version.getNextVersion();
          break;
        case "<":
          useYourVersion = ((VersionRange) yourRange).version.getPrevVersion();
          break;
        default:
          useYourVersion = ((VersionRange) yourRange).version;
          break;
      }
      if (this.contains(useYourVersion)) {
        return true;
      }

      // Special case: Versions right next to each other >1.2.6 & <1.2.7
      // There may be micro-versions or snapshot versions between them
      if (this.version.equals(useYourVersion) && ((VersionRange) yourRange).version.equals(useMyVersion)) {
        return true;
      }
    }
    // Logical ranges need to be broken down
    else if (yourRange instanceof AndRange) {
      return yourRange.intersects(this);
    }
    else if (yourRange instanceof OrRange) {
      return yourRange.intersects(this);
    }
    else {
      throw new UnsupportedOperationException();
    }
    return false;
  }