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

13
LINES

< > BotCompany Repo | #1032735 // mapValues_withoutNulls - apply function to a map's values, drop null results

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

Libraryless. Click here for Pure Java version (3820L/22K).

1  
static <A, B, C> Map<A, C> mapValues_withoutNulls(Map<A, B> map, IF1<B, C> f) {
2  
  ret mapValues_withoutNulls(f, map);
3  
}
4  
5  
static <A, B, C> Map<A, C> lambdaMapLike mapValues_withoutNulls(IF1<B, C> f, Map<A, B> map) {
6  
  Map m = similarEmptyMap(map);
7  
  for (A key, B val : map) {
8  
    O v = f.get(val);
9  
    if (v != null)
10  
      m.put(key, v);
11  
  }
12  
  ret m;
13  
}

Author comment

Began life as a copy of #1004652

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1032735
Snippet name: mapValues_withoutNulls - apply function to a map's values, drop null results
Eternal ID of this version: #1032735/2
Text MD5: 09527cde2957363c06c9e235128c19b7
Transpilation MD5: 1c877a9076db0c68dcc33aa89f2bd5f5
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-04 03:11:35
Source code size: 364 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 153 / 219
Version history: 1 change(s)
Referenced in: [show references]