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

21
LINES

< > BotCompany Repo | #1019883 // antiFilterKeys - anti-filter map by func(A) -> Bool

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

Libraryless. Click here for Pure Java version (5034L/28K).

static <A, B> Map<A, B> antiFilterKeys(Map<A, B> map, O f) {
  Map<A, B> m2 = similarEmptyMap(map);
  for (A a : keys(map)) {
    if (!isTrue(callF(f, a)))
      m2.put(a, map.get(a));
  }
  ret m2;
}

static <A, B> Map<A, B> antiFilterKeys(O f, Map<A, B> map) {
  ret antiFilterKeys(map, f);
}

static <A, B> Map<A, B> lambdaMapLike antiFilterKeys(IPred<A> f, Map<A, B> map) {
  Map<A, B> m2 = similarEmptyMap(map);
  for (A a : keys(map)) {
    if (!f.get(a))
      m2.put(a, map.get(a));
  }
  ret m2;
}

Author comment

Began life as a copy of #1011670

download  show line numbers  debug dex  old transpilations   

Travelled to 9 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1019883
Snippet name: antiFilterKeys - anti-filter map by func(A) -> Bool
Eternal ID of this version: #1019883/3
Text MD5: 19d01824e984c227dcf6d2f7f34a30bd
Transpilation MD5: 2617a4b8136dcb01c915ca8f66f45052
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-10 04:44:15
Source code size: 530 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 328 / 395
Version history: 2 change(s)
Referenced in: [show references]