mirror of
https://github.com/corda/corda.git
synced 2025-06-01 23:20:54 +00:00
Merge pull request #408 from marcinolawski/master
Missing methods in Arrays, ArrayIndexOutOfBoundsException and ClassNotFoundException.
This commit is contained in:
commit
3441e6f5aa
@ -23,6 +23,10 @@ public class ArrayIndexOutOfBoundsException extends IndexOutOfBoundsException {
|
|||||||
this(null, cause);
|
this(null, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayIndexOutOfBoundsException(int idx) {
|
||||||
|
this("Array index out of range: " + idx);
|
||||||
|
}
|
||||||
|
|
||||||
public ArrayIndexOutOfBoundsException() {
|
public ArrayIndexOutOfBoundsException() {
|
||||||
this(null, null);
|
this(null, null);
|
||||||
}
|
}
|
||||||
|
@ -25,4 +25,9 @@ public class ClassNotFoundException extends Exception {
|
|||||||
public ClassNotFoundException() {
|
public ClassNotFoundException() {
|
||||||
this(null, null);
|
this(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Throwable getException() {
|
||||||
|
return cause2;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -485,29 +485,69 @@ public class Arrays {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void checkRange(int len, int start, int stop) {
|
||||||
|
if (start < 0) {
|
||||||
|
throw new ArrayIndexOutOfBoundsException(start);
|
||||||
|
}
|
||||||
|
if (stop > len) {
|
||||||
|
throw new ArrayIndexOutOfBoundsException(stop);
|
||||||
|
}
|
||||||
|
if (start > stop) {
|
||||||
|
throw new IllegalArgumentException("start(" + start + ") > stop(" + stop + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void fill(int[] array, int value) {
|
public static void fill(int[] array, int value) {
|
||||||
for (int i=0;i<array.length;i++) {
|
for (int i=0;i<array.length;i++) {
|
||||||
array[i] = value;
|
array[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void fill(int[] array, int start, int stop, int value) {
|
||||||
|
checkRange(array.length, start, stop);
|
||||||
|
for (int i=start;i<stop;i++) {
|
||||||
|
array[i] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void fill(char[] array, char value) {
|
public static void fill(char[] array, char value) {
|
||||||
for (int i=0;i<array.length;i++) {
|
for (int i=0;i<array.length;i++) {
|
||||||
array[i] = value;
|
array[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void fill(char[] array, int start, int stop, char value) {
|
||||||
|
checkRange(array.length, start, stop);
|
||||||
|
for (int i=start;i<stop;i++) {
|
||||||
|
array[i] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void fill(short[] array, short value) {
|
public static void fill(short[] array, short value) {
|
||||||
for (int i=0;i<array.length;i++) {
|
for (int i=0;i<array.length;i++) {
|
||||||
array[i] = value;
|
array[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void fill(short[] array, int start, int stop, short value) {
|
||||||
|
checkRange(array.length, start, stop);
|
||||||
|
for (int i=start;i<stop;i++) {
|
||||||
|
array[i] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void fill(byte[] array, byte value) {
|
public static void fill(byte[] array, byte value) {
|
||||||
for (int i=0;i<array.length;i++) {
|
for (int i=0;i<array.length;i++) {
|
||||||
array[i] = value;
|
array[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void fill(byte[] array, int start, int stop, byte value) {
|
||||||
|
checkRange(array.length, start, stop);
|
||||||
|
for (int i=start;i<stop;i++) {
|
||||||
|
array[i] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void fill(boolean[] array, boolean value) {
|
public static void fill(boolean[] array, boolean value) {
|
||||||
for (int i=0;i<array.length;i++) {
|
for (int i=0;i<array.length;i++) {
|
||||||
@ -515,30 +555,65 @@ public class Arrays {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void fill(boolean[] array, int start, int stop, boolean value) {
|
||||||
|
checkRange(array.length, start, stop);
|
||||||
|
for (int i=start;i<stop;i++) {
|
||||||
|
array[i] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void fill(long[] array, long value) {
|
public static void fill(long[] array, long value) {
|
||||||
for (int i=0;i<array.length;i++) {
|
for (int i=0;i<array.length;i++) {
|
||||||
array[i] = value;
|
array[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void fill(long[] array, int start, int stop, long value) {
|
||||||
|
checkRange(array.length, start, stop);
|
||||||
|
for (int i=start;i<stop;i++) {
|
||||||
|
array[i] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void fill(float[] array, float value) {
|
public static void fill(float[] array, float value) {
|
||||||
for (int i=0;i<array.length;i++) {
|
for (int i=0;i<array.length;i++) {
|
||||||
array[i] = value;
|
array[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void fill(float[] array, int start, int stop, float value) {
|
||||||
|
checkRange(array.length, start, stop);
|
||||||
|
for (int i=start;i<stop;i++) {
|
||||||
|
array[i] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void fill(double[] array, double value) {
|
public static void fill(double[] array, double value) {
|
||||||
for (int i=0;i<array.length;i++) {
|
for (int i=0;i<array.length;i++) {
|
||||||
array[i] = value;
|
array[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void fill(double[] array, int start, int stop, double value) {
|
||||||
|
checkRange(array.length, start, stop);
|
||||||
|
for (int i=start;i<stop;i++) {
|
||||||
|
array[i] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static <T> void fill(T[] array, T value) {
|
public static <T> void fill(T[] array, T value) {
|
||||||
for (int i=0;i<array.length;i++) {
|
for (int i=0;i<array.length;i++) {
|
||||||
array[i] = value;
|
array[i] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> void fill(T[] array, int start, int stop, T value) {
|
||||||
|
checkRange(array.length, start, stop);
|
||||||
|
for (int i=start;i<stop;i++) {
|
||||||
|
array[i] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean[] copyOf(boolean[] array, int newLength) {
|
public static boolean[] copyOf(boolean[] array, int newLength) {
|
||||||
boolean[] result = new boolean[newLength];
|
boolean[] result = new boolean[newLength];
|
||||||
int length = array.length > newLength ? newLength : array.length;
|
int length = array.length > newLength ? newLength : array.length;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user