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

20
LINES

< > BotCompany Repo | #1028618 // mapToMultiMap

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

Transpiled version (9973L) is out of date.

1  
static <A, B, C extends Cl<B>> MultiMap<A, B> mapToMultiMap(Map<A, C> map) {
2  
  if (map == null) null;
3  
  MultiMap<A, B> mm = similarEmptyMultiMap(map);
4  
  for (A key, Cl<B> values : map)
5  
    mm.putAll(key, values);
6  
  ret mm;
7  
}
8  
9  
static <A, B, C> MultiMap<B, C> lambdaMapLike mapToMultiMap(IF1<A, Pair<B, C>> f, Iterable<A> l) {
10  
  new MultiMap<B, C> mm;
11  
  fOr (A o : l) {
12  
    Pair<B, C> p = f.get(o);
13  
    mm.put(p.a, p.b);
14  
  }
15  
  ret mm;
16  
}
17  
18  
static <A, B, C> MultiMap<B, C> mapToMultiMap(Iterable<A> l, IF1<A, Pair<B, C>> f) {
19  
  ret mapToMultiMap(f, l);
20  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028618
Snippet name: mapToMultiMap
Eternal ID of this version: #1028618/4
Text MD5: 6816ee9298a3abf47d46baf590327b52
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:49:38
Source code size: 568 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 220 / 340
Version history: 3 change(s)
Referenced in: [show references]