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

13
LINES

< > BotCompany Repo | #1006680 // keysWithBiggestValue

JavaX fragment (include)

1  
static <A, B extends Number> L<A> keysWithBiggestValue(Map<A, B> map) {
2  
  new L<A> l;
3  
  Number bestScore = null;
4  
  for (A key : keys(map)) {
5  
    Number score = map.get(key);
6  
    if (empty(l) || cmp(score, bestScore) >= 0) {
7  
      if (nempty(l) && cmp(score, bestScore) > 0) l.clear();
8  
      l.add(key);
9  
      bestScore = score;
10  
    }
11  
  }
12  
  ret l;
13  
}

Author comment

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: #1006680
Snippet name: keysWithBiggestValue
Eternal ID of this version: #1006680/1
Text MD5: 275c604b2e056ce921d7ce706f09fb8b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-01-31 03:41:32
Source code size: 360 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 461 / 470
Referenced in: [show references]