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.

static <A, B, C extends Cl<B>> MultiMap<A, B> mapToMultiMap(Map<A, C> map) {
  if (map == null) null;
  MultiMap<A, B> mm = similarEmptyMultiMap(map);
  for (A key, Cl<B> values : map)
    mm.putAll(key, values);
  ret mm;
}

static <A, B, C> MultiMap<B, C> lambdaMapLike mapToMultiMap(IF1<A, Pair<B, C>> f, Iterable<A> l) {
  new MultiMap<B, C> mm;
  fOr (A o : l) {
    Pair<B, C> p = f.get(o);
    mm.put(p.a, p.b);
  }
  ret mm;
}

static <A, B, C> MultiMap<B, C> mapToMultiMap(Iterable<A> l, IF1<A, Pair<B, C>> f) {
  ret mapToMultiMap(f, l);
}

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: 219 / 337
Version history: 3 change(s)
Referenced in: [show references]