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).

static <A, B> A firstKeyWithValue(Map<A, B> map, B value) {
  if (map != null) for (Map.Entry<A, B> e : map.entrySet())
    if (eq(e.getValue(), value))
      ret e.getKey();
  null;
}

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

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: 265 / 347
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1023717 - firstKeyWithNullValue
#1023907 - removeValue - remove from map by value