/** * Checks whether the point p is contained inside this interval. * * @param p point to check * @return True if the point p is contained withing the interval, false otherwise */ public boolean contains(E p) { // Check that the start point is before p boolean check1 = (includesBegin())? (first.compareTo(p) <= 0):(first.compareTo(p) < 0); // Check that the end point is after p boolean check2 = (includesEnd())? (second.compareTo(p) >= 0):(second.compareTo(p) > 0); return (check1 && check2); }
/** * Check whether this interval overlaps with the other interval. * (I.e. the intersect would not be null.) * * @param other interval to compare with * @return true if this interval overlaps the other interval */ public boolean overlaps(Interval<E> other) { if (other == null) return false; int comp12 = this.first.compareTo(other.second()); int comp21 = this.second.compareTo(other.first()); if (comp12 > 0 || comp21 < 0) { return false; } else { if (comp12 == 0) { if (!this.includesBegin() || !other.includesEnd()) { return false; } } if (comp21 == 0) { if (!this.includesEnd() || !other.includesBegin()) { return false; } } return true; } }
public boolean contains(Interval<E> other) { boolean containsOtherBegin = (other.includesBegin())? contains(other.getBegin()): containsOpen(other.getBegin()); boolean containsOtherEnd = (other.includesEnd())? contains(other.getEnd()): containsOpen(other.getEnd()); return (containsOtherBegin && containsOtherEnd); }
/** * Checks whether the point p is contained inside this interval * @param p point to check * @return True if the point p is contained withing the interval, false otherwise */ public boolean contains(E p) { // Check that the start point is before p boolean check1 = (includesBegin())? (first.compareTo(p) <= 0):(first.compareTo(p) < 0); // Check that the end point is after p boolean check2 = (includesEnd())? (second.compareTo(p) >= 0):(second.compareTo(p) > 0); return (check1 && check2); }
/** * Checks whether the point p is contained inside this interval. * * @param p point to check * @return True if the point p is contained withing the interval, false otherwise */ public boolean contains(E p) { // Check that the start point is before p boolean check1 = (includesBegin())? (first.compareTo(p) <= 0):(first.compareTo(p) < 0); // Check that the end point is after p boolean check2 = (includesEnd())? (second.compareTo(p) >= 0):(second.compareTo(p) > 0); return (check1 && check2); }
/** * Checks whether the point p is contained inside this interval. * * @param p point to check * @return True if the point p is contained withing the interval, false otherwise */ public boolean contains(E p) { // Check that the start point is before p boolean check1 = (includesBegin())? (first.compareTo(p) <= 0):(first.compareTo(p) < 0); // Check that the end point is after p boolean check2 = (includesEnd())? (second.compareTo(p) >= 0):(second.compareTo(p) > 0); return (check1 && check2); }
public boolean overlaps(Interval<E> other) { if (other == null) return false; int comp12 = this.first.compareTo(other.second()); int comp21 = this.second.compareTo(other.first()); if (comp12 > 0 || comp21 < 0) { return false; } else { if (comp12 == 0) { if (!this.includesBegin() || !other.includesEnd()) { return false; } } if (comp21 == 0) { if (!this.includesEnd() || !other.includesBegin()) { return false; } } return true; } }
/** * Check whether this interval overlaps with the other interval. * (I.e. the intersect would not be null.) * * @param other interval to compare with * @return true if this interval overlaps the other interval */ public boolean overlaps(Interval<E> other) { if (other == null) return false; int comp12 = this.first.compareTo(other.second()); int comp21 = this.second.compareTo(other.first()); if (comp12 > 0 || comp21 < 0) { return false; } else { if (comp12 == 0) { if (!this.includesBegin() || !other.includesEnd()) { return false; } } if (comp21 == 0) { if (!this.includesEnd() || !other.includesBegin()) { return false; } } return true; } }
/** * Check whether this interval overlaps with the other interval. * (I.e. the intersect would not be null.) * * @param other interval to compare with * @return true if this interval overlaps the other interval */ public boolean overlaps(Interval<E> other) { if (other == null) return false; int comp12 = this.first.compareTo(other.second()); int comp21 = this.second.compareTo(other.first()); if (comp12 > 0 || comp21 < 0) { return false; } else { if (comp12 == 0) { if (!this.includesBegin() || !other.includesEnd()) { return false; } } if (comp21 == 0) { if (!this.includesEnd() || !other.includesBegin()) { return false; } } return true; } }
/** * Check whether this interval overlaps with the other interval * (i.e. the intersect would not be null) * @param other interval to compare with * @return true if this interval overlaps the other interval */ public boolean overlaps(Interval<E> other) { if (other == null) return false; int comp12 = this.first.compareTo(other.second()); int comp21 = this.second.compareTo(other.first()); if (comp12 > 0 || comp21 < 0) { return false; } else { if (comp12 == 0) { if (!this.includesBegin() || !other.includesEnd()) { return false; } } if (comp21 == 0) { if (!this.includesEnd() || !other.includesBegin()) { return false; } } return true; } }
public boolean contains(Interval<E> other) { boolean containsOtherBegin = (other.includesBegin())? contains(other.getBegin()): containsOpen(other.getBegin()); boolean containsOtherEnd = (other.includesEnd())? contains(other.getEnd()): containsOpen(other.getEnd()); return (containsOtherBegin && containsOtherEnd); }
public boolean contains(Interval<E> other) { boolean containsOtherBegin = (other.includesBegin())? contains(other.getBegin()): containsOpen(other.getBegin()); boolean containsOtherEnd = (other.includesEnd())? contains(other.getEnd()): containsOpen(other.getEnd()); return (containsOtherBegin && containsOtherEnd); }
public boolean contains(Interval<E> other) { boolean containsOtherBegin = (other.includesBegin())? contains(other.getBegin()): containsOpen(other.getBegin()); boolean containsOtherEnd = (other.includesEnd())? contains(other.getEnd()): containsOpen(other.getEnd()); return (containsOtherBegin && containsOtherEnd); }