Libraryless. Click here for Pure Java version (3168L/17K).
1 | static O[] primitiveArrayToBoxed(O a) { |
2 | if (a == null) null; |
3 | if (a cast int[]) { |
4 | int n = a.length; |
5 | Int[] b = new[n]; |
6 | for i to n: b[i] = a[i]; |
7 | ret b; |
8 | } |
9 | if (a cast char[]) { |
10 | int n = a.length; |
11 | Char[] b = new[n]; |
12 | for i to n: b[i] = a[i]; |
13 | ret b; |
14 | } |
15 | if (a cast bool[]) { |
16 | int n = a.length; |
17 | Bool[] b = new[n]; |
18 | for i to n: b[i] = a[i]; |
19 | ret b; |
20 | } |
21 | if (a cast short[]) { |
22 | int n = a.length; |
23 | Short[] b = new[n]; |
24 | for i to n: b[i] = a[i]; |
25 | ret b; |
26 | } |
27 | if (a cast long[]) { |
28 | int n = a.length; |
29 | Long[] b = new[n]; |
30 | for i to n: b[i] = a[i]; |
31 | ret b; |
32 | } |
33 | if (a cast float[]) { |
34 | int n = a.length; |
35 | Float[] b = new[n]; |
36 | for i to n: b[i] = a[i]; |
37 | ret b; |
38 | } |
39 | if (a cast double[]) { |
40 | int n = a.length; |
41 | Double[] b = new[n]; |
42 | for i to n: b[i] = a[i]; |
43 | ret b; |
44 | } |
45 | fail("Not a primitive array: " + _getClass(a)); |
46 | } |
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1031245 |
Snippet name: | primitiveArrayToBoxed |
Eternal ID of this version: | #1031245/1 |
Text MD5: | bfec3699ccb64bba4dd919faf79bcc35 |
Transpilation MD5: | c20f021e164e76eccd774a719fcddc74 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-05-25 17:19:22 |
Source code size: | 949 bytes / 46 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 149 / 215 |
Referenced in: | [show references] |