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

31
LINES

< > BotCompany Repo | #1004652 // mapValues - apply function to a map's values

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

Transpiled version (2765L) is out of date.

1  
static Map mapValues(O func, Map map) {
2  
  Map m = similarEmptyMap(map);
3  
  for (O key : keys(map))
4  
    m.put(key, callF(func, map.get(key)));
5  
  ret m;
6  
}
7  
8  
static <A, B, C> Map<A, C> mapValues(Map<A, B> map, IF1<B, C> f) {
9  
  ret mapValues(f, map);
10  
}
11  
12  
static <A, B, C> Map<A, C> lambdaMapLike mapValues(IF1<B, C> f, Map<A, B> map) {
13  
  Map m = similarEmptyMap(map);
14  
  for (A key, B val : map)
15  
    m.put(key, f.get(val));
16  
  ret m;
17  
}
18  
19  
static Map mapValues(Map map, O func) {
20  
  ret mapValues(func, map);
21  
}
22  
23  
ifclass MultiMap
24  
  static <A, B, C> MultiMap<A, C> mapValues(IF1<B, C> func, MultiMap<A, B> mm) {
25  
    ret mapMultiMapValues(func, mm);
26  
  }
27  
  
28  
  static <A, B, C> MultiMap<A, C> mapValues(MultiMap<A, B> mm, IF1<B, C> func) {
29  
    ret mapValues(func, mm);
30  
  }
31  
endif

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1004652
Snippet name: mapValues - apply function to a map's values
Eternal ID of this version: #1004652/11
Text MD5: 0ab3cd919bc8f673dfb85184c854c3d4
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-08 10:59:35
Source code size: 790 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 717 / 821
Version history: 10 change(s)
Referenced in: [show references]