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

1  
static <A, B> Map<A, B> antiFilterKeys(Map<A, B> map, O f) {
2  
  Map<A, B> m2 = similarEmptyMap(map);
3  
  for (A a : keys(map)) {
4  
    if (!isTrue(callF(f, a)))
5  
      m2.put(a, map.get(a));
6  
  }
7  
  ret m2;
8  
}
9  
10  
static <A, B> Map<A, B> antiFilterKeys(O f, Map<A, B> map) {
11  
  ret antiFilterKeys(map, f);
12  
}
13  
14  
static <A, B> Map<A, B> lambdaMapLike antiFilterKeys(IPred<A> f, Map<A, B> map) {
15  
  Map<A, B> m2 = similarEmptyMap(map);
16  
  for (A a : keys(map)) {
17  
    if (!f.get(a))
18  
      m2.put(a, map.get(a));
19  
  }
20  
  ret m2;
21  
}

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: 253 / 299
Version history: 2 change(s)
Referenced in: [show references]