-
Notifications
You must be signed in to change notification settings - Fork 0
/
WrapperArrays.java
124 lines (123 loc) · 3.63 KB
/
WrapperArrays.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
public final class WrapperArrays {
private WrapperArrays() {}
//------------------------------------------- byte
public static Byte[] box(byte[] in) {
Byte[] out = new Byte[in.length];
for(int i = 0;i <= in.length-1;i++) {
out[i] = in[i];
}
return out;
}
public static byte[] unbox(Byte[] in) {
byte[] out = new byte[in.length];
for(int i = 0;i <= in.length-1;i++) {
out[i] = in[i];
}
return out;
}
//------------------------------------------- short
public static Short[] box(short[] in) {
Short[] out = new Short[in.length];
for(int i = 0;i <= in.length-1;i++) {
out[i] = in[i];
}
return out;
}
public static short[] unbox(Short[] in) {
short[] out = new short[in.length];
for(int i = 0;i <= in.length-1;i++) {
out[i] = in[i];
}
return out;
}
//------------------------------------------- int
public static Integer[] box(int[] in) {
Integer[] out = new Integer[in.length];
for(int i = 0;i <= in.length-1;i++) {
out[i] = in[i];
}
return out;
}
public static int[] unbox(Integer[] in) {
int[] out = new int[in.length];
for(int i = 0;i <= in.length-1;i++) {
out[i] = in[i];
}
return out;
}
//------------------------------------------- long
public static Long[] box(long[] in) {
Long[] out = new Long[in.length];
for(int i = 0;i <= in.length-1;i++) {
out[i] = in[i];
}
return out;
}
public static long[] unbox(Long[] in) {
long[] out = new long[in.length];
for(int i = 0;i <= in.length-1;i++) {
out[i] = in[i];
}
return out;
}
//------------------------------------------- float
public static Float[] box(float[] in) {
Float[] out = new Float[in.length];
for(int i = 0;i <= in.length-1;i++) {
out[i] = in[i];
}
return out;
}
public static float[] unbox(Float[] in) {
float[] out = new float[in.length];
for(int i = 0;i <= in.length-1;i++) {
out[i] = in[i];
}
return out;
}
//------------------------------------------- double
public static Double[] box(double[] in) {
Double[] out = new Double[in.length];
for(int i = 0;i <= in.length-1;i++) {
out[i] = in[i];
}
return out;
}
public static double[] unbox(Double[] in) {
double[] out = new double[in.length];
for(int i = 0;i <= in.length-1;i++) {
out[i] = in[i];
}
return out;
}
//------------------------------------------- char
public static Character[] box(char[] in) {
Character[] out = new Character[in.length];
for(int i = 0;i <= in.length-1;i++) {
out[i] = in[i];
}
return out;
}
public static char[] unbox(Character[] in) {
char[] out = new char[in.length];
for(int i = 0;i <= in.length-1;i++) {
out[i] = in[i];
}
return out;
}
//------------------------------------------- bool
public static Boolean[] box(boolean[] in) {
Boolean[] out = new Boolean[in.length];
for(int i = 0;i <= in.length-1;i++) {
out[i] = in[i];
}
return out;
}
public static boolean[] unbox(Boolean[] in) {
boolean[] out = new boolean[in.length];
for(int i = 0;i <= in.length-1;i++) {
out[i] = in[i];
}
return out;
}
}