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

32
LINES

< > BotCompany Repo | #1027245 // mapNonNullsToValue

JavaX fragment (include)

1  
static Map mapNonNullsToValue(Iterable l, O f) {
2  
  ret mapNonNullsToValue(f, l);
3  
}
4  
5  
static Map mapLike mapNonNullsToValue(O f, Iterable l) {
6  
  new HashMap map;
7  
  if (l != null) for (O o : l) {
8  
    O val = callF(f, o);
9  
    if (val != null)
10  
      map.put(o, val);
11  
  }
12  
  ret map;
13  
}
14  
15  
static <A, B, C> Map<A, C> mapNonNullsToValue(Map<A, B> map, IF2<A, B, C> f) {
16  
  new HashMap map2;
17  
  if (map != null) for (O key, value : map) {
18  
    O val = callF(f, key, value);
19  
    if (val != null)
20  
      map2.put(key, val);
21  
  }
22  
  ret map2;
23  
}
24  
25  
26  
static <A, B> Map<A, B> mapNonNullsToValue(Iterable<A> l, IF1<A, B> f) {
27  
  ret mapNonNullsToValue(f, l);
28  
}
29  
30  
static <A, B> Map<A, B> mapNonNullsToValue(IF1<A, B> f, Iterable<A> l) {
31  
  ret mapNonNullsToValue((O) f, l);
32  
}

Author comment

Began life as a copy of #1021879

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1027245
Snippet name: mapNonNullsToValue
Eternal ID of this version: #1027245/6
Text MD5: 25ef1414b8504f2151fbc16f79a2b24b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-26 16:23:53
Source code size: 775 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 167 / 201
Version history: 5 change(s)
Referenced in: [show references]