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

23
LINES

< > BotCompany Repo | #1014533 // mapKeysAndValues

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

Libraryless. Click here for Pure Java version (2750L/16K).

static Map lambdaMapLike mapKeysAndValues(O f, Map map) {
  ret mapKeysAndValues(f, f, map);
}

static Map mapKeysAndValues(O fKey, O fValue, Map map) {
  if (map == null) null;
  Map m = similarEmptyMap(map);
  for (O key, val : (Map<O>) map)
    m.put(callF(fKey, key), callF(fValue, val));
  ret m;
}

static <A, B> Map<B> mapKeysAndValues(IF1<A, B> f, Map<A> map) {
  ret mapKeysAndValues(f, f, map);
}

static <A, B, C, D> Map<C, D> mapKeysAndValues(IF1<A, C> fKey, IF1<B, D> fValue, Map<A, B> map) {
  if (map == null) null;
  Map<C, D> m = similarEmptyMap(map);
  for (A key, B val : map)
    m.put(fKey.get(key), fValue.get(val));
  ret m;
}

Author comment

Began life as a copy of #1008376

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: #1014533
Snippet name: mapKeysAndValues
Eternal ID of this version: #1014533/9
Text MD5: 600f31c6a9d11cb48ab9c5edaebd879d
Transpilation MD5: f760e423b13474cc4e299d4ec8f83e78
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-04-26 17:57:39
Source code size: 671 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 466 / 571
Version history: 8 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1014534 - unquoteKeysAndValues