compareUnsigned

fun compareUnsigned(a: ByteArray, aFromIndex: Int, aToIndex: Int, b: ByteArray, bFromIndex: Int, bToIndex: Int): Int

Compares two byte arrays lexicographically over the specified ranges, numerically treating elements as unsigned.

If the two arrays, over the specified ranges, share a common prefix then the lexicographic comparison is the result of comparing two elements, as if by Byte.compareUnsigned, at a relative index within the respective arrays that is the length of the prefix. Otherwise, one array is a proper prefix of the other and, lexicographic comparison is the result of comparing the two range lengths. (See .mismatch for the definition of a common and proper prefix.)

Return

the value 0 if, over the specified ranges, the first and second array are equal and contain the same elements in the same order; a value less than 0 if, over the specified ranges, the first array is lexicographically less than the second array; and a value greater than 0 if, over the specified ranges, the first array is lexicographically greater than the second array

Since

9

Parameters

a

the first array to compare

aFromIndex

the index (inclusive) of the first element in the first array to be compared

aToIndex

the index (exclusive) of the last element in the first array to be compared

b

the second array to compare

bFromIndex

the index (inclusive) of the first element in the second array to be compared

bToIndex

the index (exclusive) of the last element in the second array to be compared

Throws

if aFromIndex > aToIndex or if bFromIndex > bToIndex

ArrayIndexOutOfBoundsException

if aFromIndex < 0 or aToIndex > a.length or if bFromIndex < 0 or bToIndex > b.length

if either array is null