Libraryless. Click here for Pure Java version (4573L/25K).
1 | static <A, B> Map<B, A> lambdaMapLike mapToKeys(Iterable<A> l, IF1<A, B> f) { |
2 | if (l == null) null; |
3 | new HashMap<B, A> map; |
4 | for (A a : l) |
5 | map.put(f.get(a), a); |
6 | ret map; |
7 | } |
8 | |
9 | static <A, B> Map<B, A> mapToKeys(IF1<A, B> f, Iterable<A> or A[] l) { |
10 | ret mapToKeys(l, f); |
11 | } |
Began life as a copy of #1021879
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, 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/7 |
Text MD5: | 56cd981dcdd3e3ec26855a61573ef70b |
Transpilation MD5: | fd8fc4ef0997c0df34cf9b9cf14232c4 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-01-08 20:25:24 |
Source code size: | 287 bytes / 11 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 254 / 363 |
Version history: | 6 change(s) |
Referenced in: | [show references] |