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)

1  
static LinkedHashMap mapKeyAndFunction_lhm(Iterable l, O f) {
2  
  ret mapKeyAndFunction_lhm(f, l);
3  
}
4  
5  
static LinkedHashMap mapKeyAndFunction_lhm(O f, Iterable l) {
6  
  new LinkedHashMap map;
7  
  if (l != null) for (O o : l)
8  
    map.put(o, callF(f, o));
9  
  ret map;
10  
}
11  
12  
static <A, B, C> Map<A, C> mapKeyAndFunction_lhm(Map<A, B> map, IF2<A, B, C> f) {
13  
  new LinkedHashMap map2;
14  
  if (map != null) for (O key, value : map)
15  
    map2.put(key, callF(f, key, value));
16  
  ret map2;
17  
}
18  
19  
static <A, B> Map<A, B> mapKeyAndFunction_lhm(Iterable<A> l, IF1<A, B> f) {
20  
  ret mapKeyAndFunction_lhm(f, l);
21  
}

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