A DESCRIPTION OF THE REQUEST :
Please provide us with varargs version of Math.min() and Math.max(), now that we have the celebrated varargs feature in Tiger.
It would even be neatly implemented (but not strictly necessary) if it takes the following approach:
public <T extends WellOrderedNumber> T min(T ... nums) {
T ret = nums[0];
for(T num : nums)
ret = min(ret, num);
return ret;
}
which also utilises the auto-boxing / unboxing feature of the language as well.
JUSTIFICATION :
It is evidently useful to have varargs version of min() and max() compare to the existing binary comparison methods.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
long ans = Math.min(a, b, c, d, e, f);
ACTUAL -
long ans = Math.min(a, Math.min(b, Math.min(c, Math.min(d, Math.min(e, f)))));
###@###.### 2005-03-11 00:33:18 GMT
Please provide us with varargs version of Math.min() and Math.max(), now that we have the celebrated varargs feature in Tiger.
It would even be neatly implemented (but not strictly necessary) if it takes the following approach:
public <T extends WellOrderedNumber> T min(T ... nums) {
T ret = nums[0];
for(T num : nums)
ret = min(ret, num);
return ret;
}
which also utilises the auto-boxing / unboxing feature of the language as well.
JUSTIFICATION :
It is evidently useful to have varargs version of min() and max() compare to the existing binary comparison methods.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
long ans = Math.min(a, b, c, d, e, f);
ACTUAL -
long ans = Math.min(a, Math.min(b, Math.min(c, Math.min(d, Math.min(e, f)))));
###@###.### 2005-03-11 00:33:18 GMT
- duplicates
-
JDK-6358350 Math.min and Math.max should be able to accept a variable sized list
- Closed
-
JDK-6546237 New methods for java.lang.Math: median, min/max, sqr
- Closed
- relates to
-
JDK-6353471 (coll) Arrays.asList() does not support primitive arrays
- Closed
-
JDK-6356743 java.util.Arrays does not have min(T[]), max(T[]) methods.
- Closed