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

10
LINES

< > BotCompany Repo | #1023716 // firstKeyWithValue - reverse map lookup

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (51L/1K).

1  
static <A, B> A firstKeyWithValue(Map<A, B> map, B value) {
2  
  if (map != null) for (Map.Entry<A, B> e : map.entrySet())
3  
    if (eq(e.getValue(), value))
4  
      ret e.getKey();
5  
  null;
6  
}
7  
8  
static <A, B> A firstKeyWithValue(B value, Map<A, B> map) {
9  
  ret firstKeyWithValue(map, value);
10  
}

Author comment

Began life as a copy of #1008062

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1023716
Snippet name: firstKeyWithValue - reverse map lookup
Eternal ID of this version: #1023716/3
Text MD5: 3b0ad8ca6a9cc915b1cfa7e21d5de90b
Transpilation MD5: e233cec6ba8fff082b1d93efe611df27
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-12 01:20:05
Source code size: 293 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 264 / 347
Version history: 2 change(s)
Referenced in: [show references]