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

10
LINES

< > BotCompany Repo | #1014256 // replaceValuesWith - clone map, replace all values with same object

JavaX fragment (include)

1  
static <A, B> Map<A, B> replaceValuesWith(Map<A, B> map, B value) {
2  
  Map<A, B> m = similarEmptyMap(map);
3  
  for (A a : keys(map))
4  
    m.put(a, value);
5  
  ret m;
6  
}
7  
8  
static <A, B> Map<A, B> replaceValuesWith(B value, Map<A, B> map) {
9  
  ret replaceValuesWith(map, value);
10  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1014256
Snippet name: replaceValuesWith - clone map, replace all values with same object
Eternal ID of this version: #1014256/2
Text MD5: 1ab236a9b1e059170f4a0fa562767018
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-04-17 17:19:43
Source code size: 278 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 431 / 473
Version history: 1 change(s)
Referenced in: [show references]