This repository has been archived by the owner on Dec 10, 2022. It is now read-only.
/
CopyTest.java
56 lines (49 loc) · 1.93 KB
/
CopyTest.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
package javatest.utils;
import com.jtransc.io.JTranscConsole;
import java.util.Arrays;
public class CopyTest {
static public void main(String[] args) {
JTranscConsole.log("CopyTest.main()");
testOverlappingInt(new int[] {0, 1, 2, 3, 4, 5, 6}, 3);
testOverlappingByte(new byte[] {0, 1, 2, 3, 4, 5, 6}, 3);
testOverlappingLong(new long[] {0, 1, 2, 3, 4, 5, 6}, 3);
JTranscConsole.log("/CopyTest.main()");
}
private static void testOverlappingInt(int[] array1, int size) {
JTranscConsole.log("CopyTest.testOverlappingInt");
//System.out.printf("CopyTest.testOverlapping[%d]:%s\n", size, Arrays.toString(array1));
int[] array2 = new int[array1.length];
for (int a = 0; a < array1.length - size; a++) {
for (int b = 0; b < array1.length - size; b++) {
System.arraycopy(array1, 0, array2, 0, array1.length);
System.arraycopy(array2, a, array2, b, size);
System.out.println(Arrays.toString(array2));
//JTranscConsole.log(Arrays.toString(array2));
}
}
}
private static void testOverlappingByte(byte[] array1, int size) {
JTranscConsole.log("CopyTest.testOverlappingByte");
byte[] array2 = new byte[array1.length];
for (int a = 0; a < array1.length - size; a++) {
for (int b = 0; b < array1.length - size; b++) {
System.arraycopy(array1, 0, array2, 0, array1.length);
System.arraycopy(array2, a, array2, b, size);
System.out.println(Arrays.toString(array2));
//JTranscConsole.log(Arrays.toString(array2));
}
}
}
private static void testOverlappingLong(long[] array1, int size) {
JTranscConsole.log("CopyTest.testOverlappingLong");
long[] array2 = new long[array1.length];
for (int a = 0; a < array1.length - size; a++) {
for (int b = 0; b < array1.length - size; b++) {
System.arraycopy(array1, 0, array2, 0, array1.length);
System.arraycopy(array2, a, array2, b, size);
System.out.println(Arrays.toString(array2));
//JTranscConsole.log(Arrays.toString(array2));
}
}
}
}