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

10
LINES

< > BotCompany Repo | #1002303 // reverseLookup - look up a key from a value

JavaX fragment (include)

static <A, B> A reverseLookup(B value, Map<A, B> map) {
  ret reverseLookup(map, value);
}

static <A, B> A reverseLookup(Map<A, B> map, B value) {
  if (map != null && value != null) for (A key : map.keySet())
    if (eq(map.get(key), value))
      ret key;
  ret null;
}

Author comment

Began life as a copy of #1002107

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: #1002303
Snippet name: reverseLookup - look up a key from a value
Eternal ID of this version: #1002303/5
Text MD5: bf455c346d01bd2ef79bccf8c2e7ac37
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-04-20 12:58:29
Source code size: 281 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 759 / 1140
Version history: 4 change(s)
Referenced in: #1002427 - Accellerating 629 (SPIKE)
#1003000 - keysForValue - find all keys for a value
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1014345 - reverseLookupAll - look up all keys for a value
#1016016 - reverseLookupCI - look up a key from a value, case-insensitive
#1025628 - keyForValue_sync
#3000382 - Answer for ferdie (>> t = 1, f = 0)