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

20
LINES

< > BotCompany Repo | #1024294 // mapToMap - map a list to a Map using a function returning a pair; also synonym of mapMapToMap

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

Transpiled version (3909L) is out of date.

1  
static <A, B, C> Map<B, C> lambdaMapLike mapToMap(IF1<A, Pair<B, C>> f, Iterable<A> l) {
2  
  new Map<B, C> map;
3  
  fOr (A o : l) {
4  
    Pair<B, C> p = f.get(o);
5  
    map.put(p.a, p.b);
6  
  }
7  
  ret map;
8  
}
9  
10  
static <A, B, C> Map<B, C> mapToMap(Iterable<A> l, IF1<A, Pair<B, C>> f) {
11  
  ret mapToMap(f, l);
12  
}
13  
14  
static <A, B, C, D> Map<C, D> mapToMap(Map<A, B> m, IF2<A, B, Pair<C, D>> f) {
15  
  ret mapMapToMap(f, m);
16  
}
17  
18  
static <A, B, C, D> Map<C, D> mapToMap(IF2<A, B, Pair<C, D>> f, Map<A, B> m) {
19  
  ret mapMapToMap(f, m);
20  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024294
Snippet name: mapToMap - map a list to a Map using a function returning a pair; also synonym of mapMapToMap
Eternal ID of this version: #1024294/11
Text MD5: 63e95eccb9d5192c757b039065f24085
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-12-30 19:44:05
Source code size: 529 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 350 / 495
Version history: 10 change(s)
Referenced in: [show references]