Returns the intersection of this range with the given range, a range which includes those addresses in both this and the given rqnge.
@param other
@return
161422
public IPAddressSeqRange intersect(IPAddressSeqRange other) {
		IPAddress otherLower = other.getLower();
		IPAddress otherUpper = other.getUpper();
		IPAddress lower = this.getLower();
		IPAddress upper = this.getUpper();
		if(compareLowValues(lower, otherLower) <= 0) {
			if(compareLowValues(upper, otherUpper) >= 0) {
				return other;
			} else if(compareLowValues(upper, otherLower) < 0) {
				return null;
			}
			return create(otherLower, upper);
		} else if(compareLowValues(otherUpper, upper) >= 0) {
			return this;
		} else if(compareLowValues(otherUpper, lower) < 0) {
			return null;
		}
		return create(lower, otherUpper);
	}
1025558
public Set<Range<T>> differenceToFetch(Range<T> rhs)
    {
        Set<Range<T>> result;
        Set<Range<T>> intersectionSet = this.intersectionWith(rhs);
        if (intersectionSet.isEmpty())
        {
            result = new HashSet<Range<T>>();
            result.add(rhs);
        }
        else
        {
            @SuppressWarnings("unchecked")
            Range<T>[] intersections = (Range<T>[]) new Range[intersectionSet.size()];
            intersectionSet.toArray(intersections);
            if (intersections.length == 1)
            {
                result = new HashSet<Range<T>>(rhs.subtractContained(intersections[0]));
            }
            else
            {
                // intersections.length must be 2
                Range<T> first = intersections[0];
                Range<T> second = intersections[1];
                ArrayList<Range<T>> temp = rhs.subtractContained(first);

                // Because there are two intersections, subtracting only one of them
                // will yield a single Range.
                Range<T> single = temp.get(0);
                result = new HashSet<Range<T>>(single.subtractContained(second));
            }
        }
        return result;
    }
847740
def intersects_segment(self, other):
		
		i = _bisect_left(self, other)
		return ((i != 0) and (other[0] < self[i-1][1])) or ((i != len(self)) and (other[1] > self[i][0]))
1233369
public final boolean overlaps(@NotNull final HourRanges other) {
        final BitSet thisMinutes = this.toMinutes();
        final BitSet otherMinutes = other.toMinutes();
        thisMinutes.and(otherMinutes);
        return !thisMinutes.isEmpty();
    }
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));
	}
755605
public boolean isBeforeRange(final Range<T> other) {
        if (other == null) {
            return false;
        }

        return other.lowerEndpoint.isClosed ? isBefore(other.lowerEndpoint.value) : this.upperEndpoint.compareTo(other.lowerEndpoint.value) <= 0;
    }
201406
public Range intersection(final Range range) {
		int c0 = Math.max(this.start, range.start);
		int c1 = Math.min(this.end, range.end);
		return c0 <= c1 ? new Range(c0, c1) : null;
	}
334782
public void intersect(Collection<? extends Range> ranges) {
		Ranges targetRanges;
		if (ranges instanceof Ranges) {
			targetRanges = (Ranges) ranges;
		} else {
			targetRanges = new Ranges(ranges);
		}

		List<Range> newList = new ArrayList<>();
		for (Iterator<? extends Range> iterator = this.ranges.iterator(); iterator.hasNext();) {
			Range r = iterator.next();
			List<Range> hasIntersections = getHasIntersections(targetRanges, r);
			if (hasIntersections.isEmpty()) {
				iterator.remove();
			} else {
				if (hasIntersections.size() == 1) {
					Range target = hasIntersections.get(0);
					if (r.equals(target)) {
						continue;
					}
				}
				iterator.remove();
				for (Range rangeHasIntersection : hasIntersections) {
					newList.add(rangeHasIntersection.intersection(r));
				}
			}
		}
		addAll(newList);
	}
1089903
public boolean intersect(Line other, boolean limit, Vector2f result) {
		float dx1 = end.getX() - start.getX();
		float dx2 = other.end.getX() - other.start.getX();
		float dy1 = end.getY() - start.getY();
		float dy2 = other.end.getY() - other.start.getY();
		float denom = (dy2 * dx1) - (dx2 * dy1);

		if (denom == 0) {
			return false;
		}

		float ua = (dx2 * (start.getY() - other.start.getY()))
				- (dy2 * (start.getX() - other.start.getX()));
		ua /= denom;
		float ub = (dx1 * (start.getY() - other.start.getY()))
				- (dy1 * (start.getX() - other.start.getX()));
		ub /= denom;

		if ((limit) && ((ua < 0) || (ua > 1) || (ub < 0) || (ub > 1))) {
			return false;
		}

		float u = ua;

		float ix = start.getX() + (u * (end.getX() - start.getX()));
		float iy = start.getY() + (u * (end.getY() - start.getY()));

		result.set(ix, iy);
		return true;
	}
845637
public void intersectWith(LockSet other) {
        for (int i = 0; i + 1 < array.length; i += 2) {
            int valueNumber = array[i];
            if (valueNumber < 0) {
                break;
            }
            int myLockCount = array[i + 1];
            if (myLockCount <= 0) {
                continue;
            }
            int otherLockCount = other.getLockCount(valueNumber);
            if (otherLockCount <= 0) {
                /* This set holds the lock, but the other one doesn't. */
                array[i + 1] = 0;
            }
        }
    }
198533
public final boolean overlaps(@NotNull final DayOpeningHours other) {
        Contract.requireArgNotNull("other", other);
        return hourRanges.overlaps(other.hourRanges);
    }
48652
def intersection(self, other):
        
        startopen = other.startopen if self.start is None \
            else self.startopen if other.start is None \
            else other.startopen if self.start < other.start \
            else self.startopen if self.start > other.start \
            else (self.startopen or other.startopen)
        endopen = other.endopen if self.end is None \
            else self.endopen if other.end is None \
            else other.endopen if self.end > other.end \
            else self.endopen if self.end < other.end \
            else (self.endopen or other.endopen)

        new_start = self.start if other.start is None \
            else other.start if self.start is None \
            else max(self.start, other.start)
        new_end = self.end if other.end is None \
            else other.end if self.end is None \
            else min(self.end, other.end)

        interval = INTERVAL_LOOKUP[(startopen, endopen)]

        return DateRange(new_start, new_end, interval)
608235
public boolean containsRange(Range<T> otherRange) {
    if (otherRange == null) { return false; }
    return contains(otherRange.min) && contains(otherRange.max);
  }
1243078
public boolean intersects(Bbox other) {
		if (other.getX() > this.getEndPoint().getX()) {
			return false;
		}
		if (other.getY() > this.getEndPoint().getY()) {
			return false;
		}
		if (other.getEndPoint().getX() < this.getX()) {
			return false;
		}
		if (other.getEndPoint().getY() < this.getY()) {
			return false;
		}
		return true;
	}
129814
public static <C extends Comparable> boolean intersect(final Range<C> range0, final Range<C> range1) {
        checkNotNull(range0);
        checkNotNull(range1);
        return range0.isConnected(range1) && !range0.intersection(range1).isEmpty();
    }
10171
public float distanceSquared(Vector2f other) {
		float dx = other.getX() - getX();
		float dy = other.getY() - getY();
		
		return (float) (dx*dx)+(dy*dy);
	}
1374401
public double overlapAbsolute(DoubleRange other) {
    if (!intersects(other)) {
      return 0;
    }
    int loCmp = lo.compareTo(other.lo);
    int hiCmp = hi.compareTo(other.hi);
    if (loCmp >= 0 && hiCmp <= 0) {
      return this.length();
    } else if (loCmp <= 0 && hiCmp >= 0) {
      return other.length();
    } else {
      double newLo = (loCmp >= 0) ? this.lo : other.lo;
      double newHi = (hiCmp <= 0) ? this.hi : other.hi;
      return newHi - newLo;
    }
  }