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

12
LINES

< > BotCompany Repo | #1029621 // filterByValuePredicate - filter map by value predicate

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

Transpiled version (2516L) is out of date.

1  
static <A, B> Map<A, B> lambdaMapLike filterByValuePredicate(IPred<B> pred, Map<A, B> map) {
2  
  if (map == null) null;
3  
  Map<A, B> map2 = similarEmptyMap(map);
4  
  for (Map.Entry<A, B> e : map.entrySet())
5  
    if (pred.get(e.getValue()))
6  
      map2.put(e.getKey(), e.getValue());
7  
  ret map2;
8  
}
9  
10  
static <A, B> Map<A, B> filterByValuePredicate(Map<A, B> map, IPred<B> pred) {
11  
  ret filterByValuePredicate(pred, map);
12  
}

Author comment

Began life as a copy of #1028141

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: #1029621
Snippet name: filterByValuePredicate - filter map by value predicate
Eternal ID of this version: #1029621/4
Text MD5: 978c4ac8ba3fe6bf413b7eb1108686ea
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-11-30 13:49:05
Source code size: 423 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 148 / 241
Version history: 3 change(s)
Referenced in: [show references]