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)

static <A, B> Map<A, B> replaceValuesWith(Map<A, B> map, B value) {
  Map<A, B> m = similarEmptyMap(map);
  for (A a : keys(map))
    m.put(a, value);
  ret m;
}

static <A, B> Map<A, B> replaceValuesWith(B value, Map<A, B> map) {
  ret replaceValuesWith(map, value);
}

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: 357 / 396
Version history: 1 change(s)
Referenced in: [show references]