a PositiveRange is an interval of integers, given by a lower bound Min and an upper bound Max, such that 0 <= Min and Min <= Max. a PositiveRange is immutable.
Inheritance: ICloneable
示例#1
0
        /// <summary>
        /// Compares this range to the specified range. The results is true
        /// if and only if the argument has the same values as this object.
        /// </summary>
        /// <param name="that"> a positive range to compare with.</param>
        /// <returns> True if the given range has the same bounds as
        /// this object; false otherwise. </returns>
        public bool Equals(PositiveRange that)
        {
            if (null == (object)that)
            {
                return(false);
            }

            // Return true if the fields match:
            return((this.Min == that.Min) && (this.Max == that.Max));
        }
示例#2
0
        /// <summary>
        /// Checks if the given range is a subrange,
        /// bo.exp.  this.Min &lt;= range.Min and range.Max &lt;= this.Max.
        /// If the range ist not contained an ArgumentOutOfRangeException
        /// will be raised. </summary>
        /// <param name="range">The range to be checked.</param>
        /// <returns>True, if the given range lies within the bounds
        /// of this range, false otherwise.</returns>
        public bool ContainsOrFail(PositiveRange range)
        {
            if (!((this.Min <= range.Min) && (range.Max <= this.Max)))
            {
                throw new System.ArgumentOutOfRangeException(
                          new System.Text.StringBuilder(64).Append(this.ToString()).
                          Append(" does not contain ").Append(range.ToString()).ToString());
            }

            return(true);
        }
        /// <summary>
        /// Compares this range to the specified range. The results is true
        /// if and only if the argument has the same values as this object.
        /// </summary>
        /// <param name="that"> a positive range to compare with.</param>
        /// <returns> True if the given range has the same bounds as 
        /// this object; false otherwise. </returns>
        public bool Equals(PositiveRange that)
        {
            if (null == (object)that)
            {
                return false;
            }

            // Return true if the fields match:
            return (this.Min == that.Min) && (this.Max == that.Max);
        }
        /// <summary>
        /// Checks if the given range is a subrange,
        /// bo.exp.  this.Min &lt;= range.Min and range.Max &lt;= this.Max.
        /// If the range ist not contained an ArgumentOutOfRangeException
        /// will be raised. </summary>
        /// <param name="range">The range to be checked.</param>
        /// <returns>True, if the given range lies within the bounds 
        /// of this range, false otherwise.</returns>
        public bool ContainsOrFail(PositiveRange range)
        {
            if (!((this.Min <= range.Min) && (range.Max <= this.Max)))
            {
                throw new System.ArgumentOutOfRangeException(
                   new System.Text.StringBuilder(64).Append(this.ToString()).
                   Append(" does not contain ").Append(range.ToString()).ToString());
            }

            return true;
        }
 /// <summary>
 /// Checks if the given range is a subrange,
 /// bo.exp.  this.Min &lt;= range.Min and range.Max &lt;= this.Max.
 /// </summary>
 /// <param name="range">The range to be checked.</param>
 /// <returns>True, if the given range lies within the bounds 
 /// of this range, false otherwise.</returns>
 public bool Contains(PositiveRange range)
 {
     return (this.Min <= range.Min) && (range.Max <= this.Max);
 }
示例#6
0
 /// <summary>
 /// Checks if the given range is a subrange,
 /// bo.exp.  this.Min &lt;= range.Min and range.Max &lt;= this.Max.
 /// </summary>
 /// <param name="range">The range to be checked.</param>
 /// <returns>True, if the given range lies within the bounds
 /// of this range, false otherwise.</returns>
 public bool Contains(PositiveRange range)
 {
     return((this.Min <= range.Min) && (range.Max <= this.Max));
 }