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

static <A, B, C> Map<A, C> mapValues_withoutNulls(Map<A, B> map, IF1<B, C> f) {
  ret mapValues_withoutNulls(f, map);
}

static <A, B, C> Map<A, C> lambdaMapLike mapValues_withoutNulls(IF1<B, C> f, Map<A, B> map) {
  Map m = similarEmptyMap(map);
  for (A key, B val : map) {
    O v = f.get(val);
    if (v != null)
      m.put(key, v);
  }
  ret m;
}

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: 73 / 117
Version history: 1 change(s)
Referenced in: [show references]