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

23
LINES

< > BotCompany Repo | #1009585 // filterMap - filter map by func(A, B) -> Bool. also synonym of getMultipleKeys

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

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

static <A, B> Map<A, B> filterMap(Map<A, B> map, IF2<A, B, Bool> f) {
  if (map == null) null;
  Map<A, B> m2 = similarEmptyMap(map);
  for (A a, B b : map) {
    if (f.get(a, b))
      m2.put(a, b);
  }
  ret m2;
}

static <A, B> Map<A, B> curry1Like filterMap(IF2<A, B, Bool> f, Map<A, B> map) {
  ret filterMap(map, f);
}

static <A, B> Map<A, B> filterMap(Map<A, B> map, A... keys) {
  ret getMultipleKeys(map, keys);
}



static <A, B> Map<A, B> filterMap(Map<A, B> map, Iterable<A> keys) {
  ret getMultipleKeys(map, keys);
}

Author comment

Began life as a copy of #1008064

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1009585
Snippet name: filterMap - filter map by func(A, B) -> Bool. also synonym of getMultipleKeys
Eternal ID of this version: #1009585/12
Text MD5: 529e0c8ae0962bda42b78f8143b5fc5c
Transpilation MD5: 841e7d9f988f6bc523755de6f744438f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-09-13 16:06:27
Source code size: 553 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 464 / 534
Version history: 11 change(s)
Referenced in: [show references]