Libraryless. Click here for Pure Java version (5187L/29K).
1 | static <A, B extends Number> A lowest(Map<A, B> map) {
|
2 | A best = null; |
3 | Number bestScore = null; |
4 | for (A key : keys(map)) {
|
5 | Number score = map.get(key); |
6 | if (best == null || cmp(score, bestScore) < 0) {
|
7 | best = key; |
8 | bestScore = score; |
9 | } |
10 | } |
11 | ret best; |
12 | } |
13 | |
14 | static <A> A lowest(Iterable<A> l, IF1<A, Number> f) {
|
15 | ret lowestByScoreFunction(l, f); |
16 | } |
Began life as a copy of #1002040
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1003134 |
| Snippet name: | lowest - get key with lowest value. also lowestByScoreFunction |
| Eternal ID of this version: | #1003134/3 |
| Text MD5: | dd977d6f1ced1970c5a1846b335acc2a |
| Transpilation MD5: | 5f5b0f5ced6177aa38cb91bc87cb1b83 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-01-29 10:27:16 |
| Source code size: | 387 bytes / 16 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 929 / 1031 |
| Version history: | 2 change(s) |
| Referenced in: | [show references] |