Closed GoogleCodeExporter closed 9 years ago
You will want to increment i starting from 0, not 1 :)
Original comment by stephan...@gmail.com
on 11 Oct 2011 at 8:00
That's a good point, but it will stop users from passing a standard array
(varargs accept both an arbitrary number of arguments, as well as an array):
int[] array = computeArray();
int min = Ints.min(array);
Original comment by nev...@gmail.com
on 11 Oct 2011 at 8:25
Another method can be created then, it shouldn't be a big deal:
public static int min (int[] array) { // No varargs
... // Keep the same implementation as the current one.
}
Original comment by ogregoire
on 11 Oct 2011 at 9:38
@stephan,tks. The i should starting from 0, not 1. :)
@ogregoire, yes, it shouldn't be a big deal to add such a method
Original comment by liuyon...@gmail.com
on 11 Oct 2011 at 10:53
This all is perfectly sensible, but,
I'm skeptical that there really are enough people out there trying to write
Ints.min() with no arguments. I just doubt that it happens often enough that
this change would even pay for itself (for the time spent to do, review and
test the change itself, and the fact that there's that much more bulk in the
javadoc from then on).
The hazard that I think *does* occasionally happen is empty arrays -- which
this won't even catch.
Does anyone have a compelling argument?
Original comment by kevinb@google.com
on 11 Oct 2011 at 2:45
I have finished such improvements to these classes. These classes have been
attached.
Original comment by liuyon...@gmail.com
on 12 Oct 2011 at 12:54
Attachments:
[deleted comment]
There are also ten testCases modified. They are also in the attachment.
Original comment by liuyon...@gmail.com
on 12 Oct 2011 at 12:59
Attachments:
I agree with Kevin: -1 on this change. The increased API clutter isn't worth
the payoff.
Original comment by wasserman.louis
on 16 Oct 2011 at 10:43
I agree with Kevin and Louis that it isn't really worth it to add API clutter
to solve this edge-case. If people really try to call Ints.min() with no
arguments, it'll fail fast enough (at runtime)... Findbugs and other static
analysis tools might even be able to detect this at compile-time.
Sadly, liuyongpo already spent time creating a patch, before a decision was
even made as to whether this code should be added :/ I think this is a good
example of a patch that was made with good intentions, but might have been
submitted a little too fast. It might not be accepted, as mentioned by Kevin
here: https://plus.google.com/113026104107031516488/posts/ZRdtjTL1MpM (BTW, I
agree with Kevin's post and understand his reasons)
Original comment by nev...@gmail.com
on 17 Oct 2011 at 10:20
Original comment by kevinb@google.com
on 15 Nov 2011 at 10:22
This issue has been migrated to GitHub.
It can be found at https://github.com/google/guava/issues/<id>
Original comment by cgdecker@google.com
on 1 Nov 2014 at 4:15
Original comment by cgdecker@google.com
on 3 Nov 2014 at 9:09
Original issue reported on code.google.com by
liuyon...@gmail.com
on 11 Oct 2011 at 7:45