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

32
LINES

< > BotCompany Repo | #1027245 // mapNonNullsToValue

JavaX fragment (include)

static Map mapNonNullsToValue(Iterable l, O f) {
  ret mapNonNullsToValue(f, l);
}

static Map mapLike mapNonNullsToValue(O f, Iterable l) {
  new HashMap map;
  if (l != null) for (O o : l) {
    O val = callF(f, o);
    if (val != null)
      map.put(o, val);
  }
  ret map;
}

static <A, B, C> Map<A, C> mapNonNullsToValue(Map<A, B> map, IF2<A, B, C> f) {
  new HashMap map2;
  if (map != null) for (O key, value : map) {
    O val = callF(f, key, value);
    if (val != null)
      map2.put(key, val);
  }
  ret map2;
}


static <A, B> Map<A, B> mapNonNullsToValue(Iterable<A> l, IF1<A, B> f) {
  ret mapNonNullsToValue(f, l);
}

static <A, B> Map<A, B> mapNonNullsToValue(IF1<A, B> f, Iterable<A> l) {
  ret mapNonNullsToValue((O) f, l);
}

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: 165 / 199
Version history: 5 change(s)
Referenced in: [show references]