Libraryless. Click here for Pure Java version (2522L/16K).
1 | static <A> A lowestByField(Iterable<A> l, S field) {
|
2 | A lowest = null; |
3 | O lowestValue = null; |
4 | for (A a : unnull(l)) {
|
5 | O val = getOpt(a, field); |
6 | if (lowest == null || cmp(val, lowestValue) < 0) {
|
7 | lowest = a; |
8 | lowestValue = val; |
9 | } |
10 | } |
11 | ret lowest; |
12 | } |
13 | |
14 | static <A> A mapMethodLike lowestByField(S field, Iterable<A> l) {
|
15 | ret lowestByField(l, field); |
16 | } |
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1020477 |
| Snippet name: | lowestByField |
| Eternal ID of this version: | #1020477/5 |
| Text MD5: | 261b24a1d6be5f112cbbc2c49a31c412 |
| Transpilation MD5: | 2ef2adc942221a52373e0cdf1c12b19e |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-09-04 22:14:47 |
| Source code size: | 391 bytes / 16 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 585 / 707 |
| Version history: | 4 change(s) |
| Referenced in: | [show references] |