Finds and returns the index of the first mismatch between two
double
arrays, otherwise return -1 if no mismatch is found. The
index will be in the range of 0 (inclusive) up to the length (inclusive)
of the smaller array.
If the two arrays share a common prefix then the returned index is the length of the common prefix and it follows that there is a mismatch between the two elements at that index within the respective arrays. If one array is a proper prefix of the other then the returned index is the length of the smaller array and it follows that the index is only valid for the larger array. Otherwise, there is no mismatch.
Two non- null
arrays, a
and b
, share a common
prefix of length pl
if the following expression is true:
pl >= 0 &&
pl < Math.min(a.length, b.length) &&
Arrays.equals(a, 0, pl, b, 0, pl) &&
Double.compare(a[pl], b[pl]) != 0
Note that a common prefix length of 0
indicates that the first
elements from each array mismatch.
Two non- null
arrays, a
and b
, share a proper
prefix if the following expression is true:
a.length != b.length &&
Arrays.equals(a, 0, Math.min(a.length, b.length),
b, 0, Math.min(a.length, b.length))
a | the first array to be tested for a mismatch | |
b | the second array to be tested for a mismatch |
-1
.
NullPointerException
| if either array is null |
Diagram: Arrays