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

21
LINES

< > BotCompany Repo | #1018013 // mapKeyAndFunction_lhm - iterate on list, keep object as key, function result as value, use LinkedHashMap

JavaX fragment (include)

static LinkedHashMap mapKeyAndFunction_lhm(Iterable l, O f) {
  ret mapKeyAndFunction_lhm(f, l);
}

static LinkedHashMap mapKeyAndFunction_lhm(O f, Iterable l) {
  new LinkedHashMap map;
  if (l != null) for (O o : l)
    map.put(o, callF(f, o));
  ret map;
}

static <A, B, C> Map<A, C> mapKeyAndFunction_lhm(Map<A, B> map, IF2<A, B, C> f) {
  new LinkedHashMap map2;
  if (map != null) for (O key, value : map)
    map2.put(key, callF(f, key, value));
  ret map2;
}

static <A, B> Map<A, B> mapKeyAndFunction_lhm(Iterable<A> l, IF1<A, B> f) {
  ret mapKeyAndFunction_lhm(f, l);
}

Author comment

Began life as a copy of #1003239

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1018013
Snippet name: mapKeyAndFunction_lhm - iterate on list, keep object as key, function result as value, use LinkedHashMap
Eternal ID of this version: #1018013/4
Text MD5: 199de85e350e7a68f2c55ef243857aca
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-12-15 15:18:02
Source code size: 601 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 400 / 407
Version history: 3 change(s)
Referenced in: [show references]