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)

1  
static <A, B> A reverseLookup(B value, Map<A, B> map) {
2  
  ret reverseLookup(map, value);
3  
}
4  
5  
static <A, B> A reverseLookup(Map<A, B> map, B value) {
6  
  if (map != null && value != null) for (A key : map.keySet())
7  
    if (eq(map.get(key), value))
8  
      ret key;
9  
  ret null;
10  
}

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: 758 / 1140
Version history: 4 change(s)
Referenced in: [show references]