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

12
LINES

< > BotCompany Repo | #1002040 // keyWithBiggestValue

JavaX fragment (include)

1  
static <A, B extends Number> A keyWithBiggestValue(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  
}

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: 636 / 1614
Referenced in: [show references]