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.

static <A> A highestByFunction(Iterable<A> l, O f) {
  A best = null;
  O bestValue = null;
  if (l != null) for (A a : l) {
    O val = callF(f, a);
    if (best == null || cmp(val, bestValue) > 0) {
      best = a;
      bestValue = val;
    }
  }
  ret best;
}

static <A> A highestByFunction(O f, Iterable<A> l) {
  ret highestByFunction(l, f);
}

static <A> A lambdaMapLike highestByFunction(IF1<A, ? extends Comparable> f, Iterable<A> l) {
  ret highestByFunction(l, (O) f);
}

static <A> A highestByFunction(Iterable<A> l, IF1<A, ? extends Comparable> f) {
  ret highestByFunction(f, l);
}

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: 426 / 523
Version history: 6 change(s)
Referenced in: [show references]