/// /// <summary> * inRange - returns true if 'x' is within the range defined by 'this' /// * </summary> /// * <param name="x"> JDFDuration that is to be compared with 'this' </param> /// * <returns> boolean - true if 'x' is within the range defined by 'this' </returns> /// public virtual bool inRange(JDFDuration x) { JDFDuration min = this.LowerValue; JDFDuration max = this.UpperValue; return((x.isLonger(min) || x.Equals(min)) && (x.isShorter(max) || x.Equals(max))); }
// **************************************** Methods // ********************************************* /// /// <summary> * toString /// * </summary> /// * <returns> String </returns> /// public override string ToString() { if (m_left.Equals(m_right)) { return(m_left.getDurationISO()); } return(m_left.getDurationISO() + " ~ " + m_right.getDurationISO()); }
/// /// <summary> * isPartOfRange - is range 'r' within this range? /// * </summary> /// * <param name="r"> the range to test /// * </param> /// * <returns> boolean - true if range 'r' is within this range, else false </returns> /// public override bool isPartOfRange(JDFRange ra) { JDFDurationRange r = (JDFDurationRange)ra; JDFDuration min = this.LowerValue; JDFDuration r_min = r.LowerValue; JDFDuration max = this.UpperValue; JDFDuration r_max = r.UpperValue; return((r_min.isLonger(min) || r_min.Equals(min)) && (r_max.isShorter(max) || r_max.Equals(max))); }
/// /// <summary> * isUniqueOrdered - tests if 'this' is UniqueOrdered RangeList /// * </summary> /// * <returns> boolean - true if 'this' is UniqueOrdered RangeList </returns> /// public override bool isUniqueOrdered() { int siz = rangeList.Count; if (siz == 0) { return(false); // attempt to operate on a null element } List <JDFDuration> v = new List <JDFDuration>(); // vector of ranges for (int i = 0; i < siz; i++) { JDFDurationRange r = (JDFDurationRange)rangeList[i]; v.Add(r.Left); if (!r.Left.Equals(r.Right)) { v.Add(r.Right); } } int n = v.Count - 1; if (n == 0) { return(true); // single value } JDFDuration first = v[0]; JDFDuration last = v[n]; if (first.Equals(last)) { return(false); } for (int j = 0; j < n; j++) { JDFDuration @value = v[j]; JDFDuration nextvalue = v[j + 1]; if (((first.isShorter(last) && @value.isShorter(nextvalue)) || (first.isLonger(last) && @value.isLonger(nextvalue))) == false) { return(false); } } return(true); }