/// /// <summary> * inRange - tests if the given x inside of this range /// * </summary> /// * <param name="x"> comparison value /// * </param> /// * <returns> boolean - true if x in range </returns> /// public virtual bool inRange(JDFShape x) { JDFShape min = this.LowerValue; JDFShape max = this.UpperValue; return(x.isGreaterOrEqual(min) && x.isLessOrEqual(max)); }
/// /// <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) { JDFShapeRange r = (JDFShapeRange)ra; JDFShape min = this.LowerValue; JDFShape r_min = r.LowerValue; JDFShape max = this.UpperValue; JDFShape r_max = r.UpperValue; return(r_min.isGreaterOrEqual(min) && r_max.isLessOrEqual(max)); }
/// /// <summary> * isOrdered - tests if 'this' is OrderedRangeList /// * </summary> /// * <returns> boolean - true if 'this' is a OrdneredRangeList </returns> /// public override bool isOrdered() { int size = rangeList.Count; if (size == 0) { return(false); // attempt to operate on a null element } ArrayList v = new ArrayList(); // vector of ranges for (int i = 0; i < size; i++) { JDFShapeRange r = (JDFShapeRange)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 } JDFShape first = (JDFShape)v[0]; JDFShape last = (JDFShape)v[n]; for (int j = 0; j < n; j++) { JDFShape @value = (JDFShape)v[j]; JDFShape nextvalue = (JDFShape)v[j + 1]; if (((first.Equals(last) && @value.Equals(nextvalue)) || (first.isLess(last) && @value.isLessOrEqual(nextvalue)) || (first.isGreater(last) && @value.isGreaterOrEqual(nextvalue))) == false) { return(false); } } return(true); }