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

7
LINES

< > BotCompany Repo | #1028140 - mapToKeys - iterate on list, keep object as value, function result as key

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

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

static <A, B> Map<B, A> mapToKeys(Iterable<A> l, IF1<A, B> f) {
  if (l == null) null;
  new HashMap<B, A> map;
  for (A a : l)
    map.put(f.get(a), a);
  ret map;
}

Author comment

Began life as a copy of #1021879

download  show line numbers  debug dex   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, xrpafgyirdlv

No comments. add comment

Snippet ID: #1028140
Snippet name: mapToKeys - iterate on list, keep object as value, function result as key
Eternal ID of this version: #1028140/1
Text MD5: 6e23bcb399b07820aaa019755b338e12
Transpilation MD5: 7ae09b26b1622139eb4632fac8af43fc
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-05-23 13:49:00
Source code size: 172 bytes / 7 lines
Pitched / IR pitched: No / No
Views / Downloads: 30 / 53
Referenced in: [show references]

Formerly at http://tinybrain.de/1028140 & http://1028140.tinybrain.de