public Range intersect ( final Range outerRange ) throws RangeException { if ( min > outerRange . max ) { throw new IllegalArgumentException ( "range maximum must be greater or equal than " + min ) ; } if ( max < outerRange . min ) { throw new IllegalArgumentException ( "range minimum must be less or equal than " + max ) ; } int newMin = Math . max ( min , outerRange . min ) ; int newMax = Math . min ( max , outerRange . max ) ; return new Range ( newMin , newMax ) ; }
Intersects this range with the one passed . This means that the returned rand contains the maximum of both minima as minimum and the minimum of the two maxima as maximum .