-
Notifications
You must be signed in to change notification settings - Fork 2
/
Y.java
271 lines (249 loc) · 7.13 KB
/
Y.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
package qgb;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import qgb.annotation.tested;
/**QGB's java basic array method**/
public class Y {
public static void main(String [] args) {
ArrayList<String> als=new ArrayList<>();
for (int i = 0; i < 12; i++) {
als.add("aa"+i+"bb");
}
//U.print(als);
U.print(ListToStr(als, "\n"));
if (true) {
return;
}
String stin=U.readSt("y.txt");
//"char","Character"
String[][] yyc={{"boolean","Boolean"},{"byte","Byte"},{"char","Character"},
{"double","Double"},{"float","Float"},{"int","Integer"},{"long","Long"},{"short","Short"}};
for (int i = 0; i < yyc.length; i++) {
String str=T.replaceAll(stin, "char", yyc[i][0]);
str=T.replaceAll(str, "Character", yyc[i][1]);
U.print(str);
//U.msgbox();
}
}
/***/
public static ArrayList<Object> addArrayToArrayList(ArrayList<Object> aal,Object[] ayo) {
for (int i = 0; i < ayo.length; i++) {
aal.add(ayo[i]);
}
return aal;
}
public static ArrayList<Object> ArrayToArrayList(Object[] ayo) {
return addArrayToArrayList(new ArrayList<Object>(), ayo);
}
/***************************************/
//去掉数组中重复的值
public static <Type> List<Type> delMuti(List<Type> str) {
List<Type> list = new ArrayList<Type>();
for (int i=0; i<str.size(); i++) {
if(!list.contains(str.get(i))) {
list.add(str.get(i));
}
}
//返回一个包含所有对象的指定类型的数组
return list;
}
public static <Type> Type[] delMuti(Type[] str) {
return delMuti(Arrays.asList(str)).toArray(str);
}
public static char[] delMuti(char[] ayc) {
return unboxing(delMuti(boxing(ayc))) ;
}
//////////// boxing unboxing//////////////////////////////////////////////
/**boolean[] Boolean[]**/
public static Boolean[] boxing(boolean[] ay) {
Boolean[] y=new Boolean[ay.length];
for (int i = 0; i < ay.length; i++) {
y[i]=new Boolean(ay[i]);
}
return y;
}
public static boolean[] unboxing(Boolean[] ay) {
boolean[] y=new boolean[ay.length];
for (int i = 0; i < ay.length; i++) {
y[i]=ay[i].booleanValue();
}
return y;
}
/**byte[] Byte[]**/
public static Byte[] boxing(byte[] ay) {
Byte[] y=new Byte[ay.length];
for (int i = 0; i < ay.length; i++) {
y[i]=new Byte(ay[i]);
}
return y;
}
public static byte[] unboxing(Byte[] ay) {
byte[] y=new byte[ay.length];
for (int i = 0; i < ay.length; i++) {
y[i]=ay[i].byteValue();
}
return y;
}
/**char[] Character[]**/
public static Character[] boxing(char[] ay) {
Character[] y=new Character[ay.length];
for (int i = 0; i < ay.length; i++) {
y[i]=new Character(ay[i]);
}
return y;
}
public static char[] unboxing(Character[] ay) {
char[] y=new char[ay.length];
for (int i = 0; i < ay.length; i++) {
y[i]=ay[i].charValue();
}
return y;
}
/**double[] Double[]**/
public static Double[] boxing(double[] ay) {
Double[] y=new Double[ay.length];
for (int i = 0; i < ay.length; i++) {
y[i]=new Double(ay[i]);
}
return y;
}
public static double[] unboxing(Double[] ay) {
double[] y=new double[ay.length];
for (int i = 0; i < ay.length; i++) {
y[i]=ay[i].doubleValue();
}
return y;
}
/**float[] Float[]**/
public static Float[] boxing(float[] ay) {
Float[] y=new Float[ay.length];
for (int i = 0; i < ay.length; i++) {
y[i]=new Float(ay[i]);
}
return y;
}
public static float[] unboxing(Float[] ay) {
float[] y=new float[ay.length];
for (int i = 0; i < ay.length; i++) {
y[i]=ay[i].floatValue();
}
return y;
}
/**int[] Integer[]**/
public static Integer[] boxing(int[] ay) {
Integer[] y=new Integer[ay.length];
for (int i = 0; i < ay.length; i++) {
y[i]=new Integer(ay[i]);
}
return y;
}
public static int[] unboxing(Integer[] ay) {
int[] y=new int[ay.length];
for (int i = 0; i < ay.length; i++) {
y[i]=ay[i].intValue();
}
return y;
}
/**long[] Long[]**/
public static Long[] boxing(long[] ay) {
Long[] y=new Long[ay.length];
for (int i = 0; i < ay.length; i++) {
y[i]=new Long(ay[i]);
}
return y;
}
public static long[] unboxing(Long[] ay) {
long[] y=new long[ay.length];
for (int i = 0; i < ay.length; i++) {
y[i]=ay[i].longValue();
}
return y;
}
/**short[] Short[]**/
public static Short[] boxing(short[] ay) {
Short[] y=new Short[ay.length];
for (int i = 0; i < ay.length; i++) {
y[i]=new Short(ay[i]);
}
return y;
}
public static short[] unboxing(Short[] ay) {
short[] y=new short[ay.length];
for (int i = 0; i < ay.length; i++) {
y[i]=ay[i].shortValue();
}
return y;
}
////////////// boxing unboxing End////////////////////////////////////////////////
public static String[] del_one_element(String[] ayst,int aidel) {
/*String [] str = {"Java", "C++", "Php", "C#", "Python"};
for (String elementA:ayst ) {
System.out.print(elementA + " ");
} */
//删除php
List<String> list = new ArrayList<String>();
for (int i=0; i<ayst.length; i++) {
list.add(ayst[i]);
}
list.remove(aidel); //list.remove("Php")
//System.out.println();
return( list.toArray(new String[1]));
/*String[] newStr = list.toArray(new String[1]); //返回一个包含所有对象的指定类型的数组
for (String elementB:newStr ) {
System.out.print(elementB + " ");
}
System.out.println(); */
}
public static String ArrayToStr(String[] ayst, String ast_separator) {
String str="";
//U.print("["+ast_separator+"]");
for (int i = 0; i < ayst.length; i++) {
str=str+ayst[i]+ast_separator;
}
return str;
}
@tested//2015-06-26 23:51:09
public static String ListToStr(Iterable<?> ay, String ast_separator) {
StringBuilder sb=new StringBuilder();
/**Each call to ay.iterator() returns a initialization Iterator*/
Iterator<?> it=ay.iterator();
while (it.hasNext()) {
sb.append(it.next().toString()+ast_separator);
//U.msgbox(sb.toString());
}
return sb.toString();
}
/**自动剔除""与null值</br>
* Windows 换行符 \r\n**/
public static String[] StrToArray(String ast,String ast_separator) {
String[] yst=ast.split(ast_separator);
return delTarget(yst,"");
}
/**删除aySource中的ayTarget。</br>自动删除null值**/
public static <Type> Type[] delTarget(Type[] aySource, Type... ayTarget) {
if (ayTarget==null||ayTarget.length<1) return aySource;
int ir=0;
for (int i = 0; i < aySource.length; i++) {
for (int j = 0; j < ayTarget.length; j++) {
if (aySource[i]==null||aySource[i].equals(ayTarget[j])) {
break;
}
if (j==(ayTarget.length-1)) {
aySource[ir]=aySource[i];
ir++;
//yT[++ir]=aySource[i];
}
}
}
return Arrays.copyOfRange(aySource, 0, ir);
}
public static String[] ObjectsToYStr(Object[] ayo) {
String[] yst = new String[ayo.length];
for (int i = 0; i < ayo.length; i++) {
yst[i] = ayo[i].toString();
}
return yst;
}
}