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

13
LINES

< > BotCompany Repo | #1006680 // keysWithBiggestValue

JavaX fragment (include)

static <A, B extends Number> L<A> keysWithBiggestValue(Map<A, B> map) {
  new L<A> l;
  Number bestScore = null;
  for (A key : keys(map)) {
    Number score = map.get(key);
    if (empty(l) || cmp(score, bestScore) >= 0) {
      if (nempty(l) && cmp(score, bestScore) > 0) l.clear();
      l.add(key);
      bestScore = score;
    }
  }
  ret l;
}

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