Libraryless. Click here for Pure Java version (3933L/22K).
1 | static O[] mapToObjectArray(Map map) { |
2 | new L l; |
3 | for (O o : keys(map)) { |
4 | l.add(o); |
5 | l.add(map.get(o)); |
6 | } |
7 | ret toObjectArray(l); |
8 | } |
9 | |
10 | static O[] mapToObjectArray(O f, Cl l) { |
11 | int n = l(l); |
12 | O[] array = new[n]; |
13 | if (n != 0) { |
14 | Iterator it = iterator(l); |
15 | for i to n: |
16 | array[i] = callF(f, it.next()); |
17 | } |
18 | ret array; |
19 | } |
20 | |
21 | static O[] mapToObjectArray(O f, O[] l) { |
22 | int n = l(l); |
23 | O[] array = new[n]; |
24 | for i to n: |
25 | array[i] = callF(f, l[i]); |
26 | ret array; |
27 | } |
28 | |
29 | static <A> O[] mapToObjectArray(Cl<A> l, IF1<A, O> f) { |
30 | ret mapToObjectArray(f, l); |
31 | } |
32 | |
33 | static <A> O[] mapToObjectArray(A[] l, IF1<A, O> f) { |
34 | ret mapToObjectArray(f, l); |
35 | } |
36 | |
37 | static <A> O[] lambdaMapLike mapToObjectArray(IF1<A, O> f, A[] l) { |
38 | int n = l(l); |
39 | O[] array = new[n]; |
40 | for i to n: |
41 | array[i] = f.get(l[i]); |
42 | ret array; |
43 | } |
44 | |
45 | static <A> O[] lambdaMapLike mapToObjectArray(IF1<A, O> f, Cl<A> l) { |
46 | int n = l(l); |
47 | O[] array = new[n]; |
48 | if (n != 0) { |
49 | Iterator it = iterator(l); |
50 | for i to n: |
51 | array[i] = callF(f, it.next()); |
52 | } |
53 | ret array; |
54 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1006543 |
Snippet name: | mapToObjectArray - interleave keys and values; also toObjectArray(map(...)) |
Eternal ID of this version: | #1006543/13 |
Text MD5: | 4ffae886d086cbbc3c2003168bccafe9 |
Transpilation MD5: | 96bba04744eb412fedc270621221eab1 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-13 18:54:41 |
Source code size: | 1105 bytes / 54 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 607 / 791 |
Version history: | 12 change(s) |
Referenced in: | [show references] |