Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

24
LINES

< > BotCompany Repo | #1016781 // highestByFunction

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (2498L) is out of date.

1  
static <A> A highestByFunction(Iterable<A> l, O f) {
2  
  A best = null;
3  
  O bestValue = null;
4  
  if (l != null) for (A a : l) {
5  
    O val = callF(f, a);
6  
    if (best == null || cmp(val, bestValue) > 0) {
7  
      best = a;
8  
      bestValue = val;
9  
    }
10  
  }
11  
  ret best;
12  
}
13  
14  
static <A> A highestByFunction(O f, Iterable<A> l) {
15  
  ret highestByFunction(l, f);
16  
}
17  
18  
static <A> A lambdaMapLike highestByFunction(IF1<A, ? extends Comparable> f, Iterable<A> l) {
19  
  ret highestByFunction(l, (O) f);
20  
}
21  
22  
static <A> A highestByFunction(Iterable<A> l, IF1<A, ? extends Comparable> f) {
23  
  ret highestByFunction(f, l);
24  
}

Author comment

Began life as a copy of #1011185

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1016781
Snippet name: highestByFunction
Eternal ID of this version: #1016781/7
Text MD5: 2ea90adf65fb21ae87380e38268e31ea
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-16 19:09:58
Source code size: 619 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 428 / 529
Version history: 6 change(s)
Referenced in: [show references]