| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.util; |
| 22 |
|
|
| 23 |
|
import java.util.Arrays; |
| 24 |
|
|
| 25 |
|
import java.util.Objects; |
| 26 |
|
|
| |
|
| 0% |
Uncovered Elements: 39 (39) |
Complexity: 11 |
Complexity Density: 0.52 |
|
| 27 |
|
public class ArrayUtils |
| 28 |
|
{ |
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
@param |
| 33 |
|
|
| |
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 34 |
0 |
public static void reverseIntArray(int[] arr)... |
| 35 |
|
{ |
| 36 |
0 |
if (arr != null) |
| 37 |
|
{ |
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
0 |
int last = arr.length - 1; |
| 43 |
0 |
for (int k = 0; k < arr.length / 2; k++) |
| 44 |
|
{ |
| 45 |
0 |
int temp = arr[k]; |
| 46 |
0 |
arr[k] = arr[last - k]; |
| 47 |
0 |
arr[last - k] = temp; |
| 48 |
|
} |
| 49 |
|
} |
| 50 |
|
} |
| 51 |
|
|
| |
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
| 52 |
0 |
public static <T> T[] concatArrays(T[]... arrays)... |
| 53 |
|
{ |
| 54 |
0 |
if (arrays == null) |
| 55 |
0 |
return null; |
| 56 |
0 |
if (arrays.length == 1) |
| 57 |
0 |
return arrays[0]; |
| 58 |
|
|
| 59 |
0 |
T[] result = arrays[0]; |
| 60 |
0 |
for (int i = 1; i < arrays.length; i++) |
| 61 |
|
{ |
| 62 |
0 |
result = concatTwoArrays(result, arrays[i]); |
| 63 |
|
} |
| 64 |
0 |
return result; |
| 65 |
|
} |
| 66 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 67 |
0 |
private static <T> T[] concatTwoArrays(T[] array1, T[] array2)... |
| 68 |
|
{ |
| 69 |
0 |
T[] result = Arrays.copyOf(array1, array1.length + array2.length); |
| 70 |
0 |
System.arraycopy(array2, 0, result, array1.length, array2.length); |
| 71 |
0 |
return result; |
| 72 |
|
} |
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| 79 |
|
@param |
| 80 |
|
|
| 81 |
|
@param |
| 82 |
|
|
| 83 |
|
@return |
| 84 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
| 85 |
0 |
public static int indexOf(Object[] arr, Object item)... |
| 86 |
|
{ |
| 87 |
0 |
for (int i = 0; i < arr.length; i++) |
| 88 |
|
{ |
| 89 |
0 |
if (Objects.equals(arr[i], item)) |
| 90 |
0 |
return i; |
| 91 |
|
} |
| 92 |
0 |
return -1; |
| 93 |
|
} |
| 94 |
|
} |