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

12
LINES

< > BotCompany Repo | #1002040 // keyWithBiggestValue

JavaX fragment (include)

static <A, B extends Number> A keyWithBiggestValue(Map<A, B> map) {
  A best = null;
  Number bestScore = null;
  for (A key : keys(map)) {
    Number score = map.get(key);
    if (best == null || cmp(score, bestScore) > 0) {
      best = key;
      bestScore = score;
    }
  }
  ret best;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1002040
Snippet name: keyWithBiggestValue
Eternal ID of this version: #1002040/1
Text MD5: 51cc1f6da6ff41db2d8e057996181699
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-12-15 00:16:12
Source code size: 303 bytes / 12 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 706 / 1691
Referenced in: #1002421 - highest - synonym of keyWithBiggestValue
#1002427 - Accellerating 629 (SPIKE)
#1003134 - lowest - get key with lowest value. also lowestByScoreFunction
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1006680 - keysWithBiggestValue
#3000382 - Answer for ferdie (>> t = 1, f = 0)