[sdlib] adoption of e632d58936

Nullable Array.contentEquals/contentHashCode/contentToString #KT-34161
This commit is contained in:
Vasily Levchenko
2020-03-16 13:08:49 +01:00
parent f0d42a590b
commit 09d896d485
2 changed files with 441 additions and 80 deletions
@@ -240,7 +240,25 @@ public actual fun CharArray.asList(): List<Char> {
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`. * For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual infix fun <T> Array<out T>.contentDeepEquals(other: Array<out T>): Boolean { public actual infix fun <T> Array<out T>.contentDeepEquals(other: Array<out T>): Boolean {
return this.contentDeepEquals(other)
}
/**
* Returns `true` if the two specified arrays are *deeply* equal to one another,
* i.e. contain the same number of the same elements in the same order.
*
* The specified arrays are also considered deeply equal if both are `null`.
*
* If two corresponding elements are nested arrays, they are also compared deeply.
* If any of arrays contains itself on any nesting level the behavior is undefined.
*
* The elements of other types are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/
@SinceKotlin("1.4")
public actual infix fun <T> Array<out T>?.contentDeepEquals(other: Array<out T>?): Boolean {
return contentDeepEqualsImpl(other) return contentDeepEqualsImpl(other)
} }
@@ -251,7 +269,19 @@ public actual infix fun <T> Array<out T>.contentDeepEquals(other: Array<out T>):
* If any of arrays contains itself on any nesting level the behavior is undefined. * If any of arrays contains itself on any nesting level the behavior is undefined.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual fun <T> Array<out T>.contentDeepHashCode(): Int { public actual fun <T> Array<out T>.contentDeepHashCode(): Int {
return this.contentDeepHashCode()
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
* Nested arrays are treated as lists too.
*
* If any of arrays contains itself on any nesting level the behavior is undefined.
*/
@SinceKotlin("1.4")
public actual fun <T> Array<out T>?.contentDeepHashCode(): Int {
return contentDeepHashCodeImpl() return contentDeepHashCodeImpl()
} }
@@ -265,7 +295,22 @@ public actual fun <T> Array<out T>.contentDeepHashCode(): Int {
* @sample samples.collections.Arrays.ContentOperations.contentDeepToString * @sample samples.collections.Arrays.ContentOperations.contentDeepToString
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual fun <T> Array<out T>.contentDeepToString(): String { public actual fun <T> Array<out T>.contentDeepToString(): String {
return this.contentDeepToString()
}
/**
* Returns a string representation of the contents of this array as if it is a [List].
* Nested arrays are treated as lists too.
*
* If any of arrays contains itself on any nesting level that reference
* is rendered as `"[...]"` to prevent recursion.
*
* @sample samples.collections.Arrays.ContentOperations.contentDeepToString
*/
@SinceKotlin("1.4")
public actual fun <T> Array<out T>?.contentDeepToString(): String {
return contentDeepToStringImpl() return contentDeepToStringImpl()
} }
@@ -277,13 +322,9 @@ public actual fun <T> Array<out T>.contentDeepToString(): String {
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`. * For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual infix fun <T> Array<out T>.contentEquals(other: Array<out T>): Boolean { public actual infix fun <T> Array<out T>.contentEquals(other: Array<out T>): Boolean {
if (this === other) return true return this.contentEquals(other)
if (size != other.size) return false
for (i in indices) {
if (this[i] != other[i]) return false
}
return true
} }
/** /**
@@ -294,13 +335,9 @@ public actual infix fun <T> Array<out T>.contentEquals(other: Array<out T>): Boo
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`. * For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual infix fun ByteArray.contentEquals(other: ByteArray): Boolean { public actual infix fun ByteArray.contentEquals(other: ByteArray): Boolean {
if (this === other) return true return this.contentEquals(other)
if (size != other.size) return false
for (i in indices) {
if (this[i] != other[i]) return false
}
return true
} }
/** /**
@@ -311,13 +348,9 @@ public actual infix fun ByteArray.contentEquals(other: ByteArray): Boolean {
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`. * For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual infix fun ShortArray.contentEquals(other: ShortArray): Boolean { public actual infix fun ShortArray.contentEquals(other: ShortArray): Boolean {
if (this === other) return true return this.contentEquals(other)
if (size != other.size) return false
for (i in indices) {
if (this[i] != other[i]) return false
}
return true
} }
/** /**
@@ -328,13 +361,9 @@ public actual infix fun ShortArray.contentEquals(other: ShortArray): Boolean {
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`. * For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual infix fun IntArray.contentEquals(other: IntArray): Boolean { public actual infix fun IntArray.contentEquals(other: IntArray): Boolean {
if (this === other) return true return this.contentEquals(other)
if (size != other.size) return false
for (i in indices) {
if (this[i] != other[i]) return false
}
return true
} }
/** /**
@@ -345,13 +374,9 @@ public actual infix fun IntArray.contentEquals(other: IntArray): Boolean {
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`. * For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual infix fun LongArray.contentEquals(other: LongArray): Boolean { public actual infix fun LongArray.contentEquals(other: LongArray): Boolean {
if (this === other) return true return this.contentEquals(other)
if (size != other.size) return false
for (i in indices) {
if (this[i] != other[i]) return false
}
return true
} }
/** /**
@@ -362,13 +387,9 @@ public actual infix fun LongArray.contentEquals(other: LongArray): Boolean {
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`. * For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual infix fun FloatArray.contentEquals(other: FloatArray): Boolean { public actual infix fun FloatArray.contentEquals(other: FloatArray): Boolean {
if (this === other) return true return this.contentEquals(other)
if (size != other.size) return false
for (i in indices) {
if (!this[i].equals(other[i])) return false
}
return true
} }
/** /**
@@ -379,8 +400,138 @@ public actual infix fun FloatArray.contentEquals(other: FloatArray): Boolean {
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`. * For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual infix fun DoubleArray.contentEquals(other: DoubleArray): Boolean { public actual infix fun DoubleArray.contentEquals(other: DoubleArray): Boolean {
return this.contentEquals(other)
}
/**
* Returns `true` if the two specified arrays are *structurally* equal to one another,
* i.e. contain the same number of the same elements in the same order.
*
* The elements are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/
@SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual infix fun BooleanArray.contentEquals(other: BooleanArray): Boolean {
return this.contentEquals(other)
}
/**
* Returns `true` if the two specified arrays are *structurally* equal to one another,
* i.e. contain the same number of the same elements in the same order.
*
* The elements are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/
@SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual infix fun CharArray.contentEquals(other: CharArray): Boolean {
return this.contentEquals(other)
}
/**
* Returns `true` if the two specified arrays are *structurally* equal to one another,
* i.e. contain the same number of the same elements in the same order.
*
* The elements are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/
@SinceKotlin("1.4")
public actual infix fun <T> Array<out T>?.contentEquals(other: Array<out T>?): Boolean {
if (this === other) return true if (this === other) return true
if (this === null || other === null) return false
if (size != other.size) return false
for (i in indices) {
if (this[i] != other[i]) return false
}
return true
}
/**
* Returns `true` if the two specified arrays are *structurally* equal to one another,
* i.e. contain the same number of the same elements in the same order.
*
* The elements are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/
@SinceKotlin("1.4")
public actual infix fun ByteArray?.contentEquals(other: ByteArray?): Boolean {
if (this === other) return true
if (this === null || other === null) return false
if (size != other.size) return false
for (i in indices) {
if (this[i] != other[i]) return false
}
return true
}
/**
* Returns `true` if the two specified arrays are *structurally* equal to one another,
* i.e. contain the same number of the same elements in the same order.
*
* The elements are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/
@SinceKotlin("1.4")
public actual infix fun ShortArray?.contentEquals(other: ShortArray?): Boolean {
if (this === other) return true
if (this === null || other === null) return false
if (size != other.size) return false
for (i in indices) {
if (this[i] != other[i]) return false
}
return true
}
/**
* Returns `true` if the two specified arrays are *structurally* equal to one another,
* i.e. contain the same number of the same elements in the same order.
*
* The elements are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/
@SinceKotlin("1.4")
public actual infix fun IntArray?.contentEquals(other: IntArray?): Boolean {
if (this === other) return true
if (this === null || other === null) return false
if (size != other.size) return false
for (i in indices) {
if (this[i] != other[i]) return false
}
return true
}
/**
* Returns `true` if the two specified arrays are *structurally* equal to one another,
* i.e. contain the same number of the same elements in the same order.
*
* The elements are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/
@SinceKotlin("1.4")
public actual infix fun LongArray?.contentEquals(other: LongArray?): Boolean {
if (this === other) return true
if (this === null || other === null) return false
if (size != other.size) return false
for (i in indices) {
if (this[i] != other[i]) return false
}
return true
}
/**
* Returns `true` if the two specified arrays are *structurally* equal to one another,
* i.e. contain the same number of the same elements in the same order.
*
* The elements are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/
@SinceKotlin("1.4")
public actual infix fun FloatArray?.contentEquals(other: FloatArray?): Boolean {
if (this === other) return true
if (this === null || other === null) return false
if (size != other.size) return false if (size != other.size) return false
for (i in indices) { for (i in indices) {
if (!this[i].equals(other[i])) return false if (!this[i].equals(other[i])) return false
@@ -395,9 +546,28 @@ public actual infix fun DoubleArray.contentEquals(other: DoubleArray): Boolean {
* The elements are compared for equality with the [equals][Any.equals] function. * The elements are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`. * For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.4")
public actual infix fun BooleanArray.contentEquals(other: BooleanArray): Boolean { public actual infix fun DoubleArray?.contentEquals(other: DoubleArray?): Boolean {
if (this === other) return true if (this === other) return true
if (this === null || other === null) return false
if (size != other.size) return false
for (i in indices) {
if (!this[i].equals(other[i])) return false
}
return true
}
/**
* Returns `true` if the two specified arrays are *structurally* equal to one another,
* i.e. contain the same number of the same elements in the same order.
*
* The elements are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/
@SinceKotlin("1.4")
public actual infix fun BooleanArray?.contentEquals(other: BooleanArray?): Boolean {
if (this === other) return true
if (this === null || other === null) return false
if (size != other.size) return false if (size != other.size) return false
for (i in indices) { for (i in indices) {
if (this[i] != other[i]) return false if (this[i] != other[i]) return false
@@ -412,9 +582,10 @@ public actual infix fun BooleanArray.contentEquals(other: BooleanArray): Boolean
* The elements are compared for equality with the [equals][Any.equals] function. * The elements are compared for equality with the [equals][Any.equals] function.
* For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`. * For floating point numbers it means that `NaN` is equal to itself and `-0.0` is not equal to `0.0`.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.4")
public actual infix fun CharArray.contentEquals(other: CharArray): Boolean { public actual infix fun CharArray?.contentEquals(other: CharArray?): Boolean {
if (this === other) return true if (this === other) return true
if (this === null || other === null) return false
if (size != other.size) return false if (size != other.size) return false
for (i in indices) { for (i in indices) {
if (this[i] != other[i]) return false if (this[i] != other[i]) return false
@@ -426,84 +597,89 @@ public actual infix fun CharArray.contentEquals(other: CharArray): Boolean {
* Returns a hash code based on the contents of this array as if it is [List]. * Returns a hash code based on the contents of this array as if it is [List].
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual fun <T> Array<out T>.contentHashCode(): Int { public actual fun <T> Array<out T>.contentHashCode(): Int {
var result = 1 return this.contentHashCode()
for (element in this)
result = 31 * result + element.hashCode()
return result
} }
/** /**
* Returns a hash code based on the contents of this array as if it is [List]. * Returns a hash code based on the contents of this array as if it is [List].
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual fun ByteArray.contentHashCode(): Int { public actual fun ByteArray.contentHashCode(): Int {
var result = 1 return this.contentHashCode()
for (element in this)
result = 31 * result + element.hashCode()
return result
} }
/** /**
* Returns a hash code based on the contents of this array as if it is [List]. * Returns a hash code based on the contents of this array as if it is [List].
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual fun ShortArray.contentHashCode(): Int { public actual fun ShortArray.contentHashCode(): Int {
var result = 1 return this.contentHashCode()
for (element in this)
result = 31 * result + element.hashCode()
return result
} }
/** /**
* Returns a hash code based on the contents of this array as if it is [List]. * Returns a hash code based on the contents of this array as if it is [List].
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual fun IntArray.contentHashCode(): Int { public actual fun IntArray.contentHashCode(): Int {
var result = 1 return this.contentHashCode()
for (element in this)
result = 31 * result + element.hashCode()
return result
} }
/** /**
* Returns a hash code based on the contents of this array as if it is [List]. * Returns a hash code based on the contents of this array as if it is [List].
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual fun LongArray.contentHashCode(): Int { public actual fun LongArray.contentHashCode(): Int {
var result = 1 return this.contentHashCode()
for (element in this)
result = 31 * result + element.hashCode()
return result
} }
/** /**
* Returns a hash code based on the contents of this array as if it is [List]. * Returns a hash code based on the contents of this array as if it is [List].
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual fun FloatArray.contentHashCode(): Int { public actual fun FloatArray.contentHashCode(): Int {
var result = 1 return this.contentHashCode()
for (element in this)
result = 31 * result + element.hashCode()
return result
} }
/** /**
* Returns a hash code based on the contents of this array as if it is [List]. * Returns a hash code based on the contents of this array as if it is [List].
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual fun DoubleArray.contentHashCode(): Int { public actual fun DoubleArray.contentHashCode(): Int {
var result = 1 return this.contentHashCode()
for (element in this)
result = 31 * result + element.hashCode()
return result
} }
/** /**
* Returns a hash code based on the contents of this array as if it is [List]. * Returns a hash code based on the contents of this array as if it is [List].
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual fun BooleanArray.contentHashCode(): Int { public actual fun BooleanArray.contentHashCode(): Int {
return this.contentHashCode()
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual fun CharArray.contentHashCode(): Int {
return this.contentHashCode()
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.4")
public actual fun <T> Array<out T>?.contentHashCode(): Int {
if (this === null) return 0
var result = 1 var result = 1
for (element in this) for (element in this)
result = 31 * result + element.hashCode() result = 31 * result + element.hashCode()
@@ -513,8 +689,93 @@ public actual fun BooleanArray.contentHashCode(): Int {
/** /**
* Returns a hash code based on the contents of this array as if it is [List]. * Returns a hash code based on the contents of this array as if it is [List].
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.4")
public actual fun CharArray.contentHashCode(): Int { public actual fun ByteArray?.contentHashCode(): Int {
if (this === null) return 0
var result = 1
for (element in this)
result = 31 * result + element.hashCode()
return result
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.4")
public actual fun ShortArray?.contentHashCode(): Int {
if (this === null) return 0
var result = 1
for (element in this)
result = 31 * result + element.hashCode()
return result
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.4")
public actual fun IntArray?.contentHashCode(): Int {
if (this === null) return 0
var result = 1
for (element in this)
result = 31 * result + element.hashCode()
return result
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.4")
public actual fun LongArray?.contentHashCode(): Int {
if (this === null) return 0
var result = 1
for (element in this)
result = 31 * result + element.hashCode()
return result
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.4")
public actual fun FloatArray?.contentHashCode(): Int {
if (this === null) return 0
var result = 1
for (element in this)
result = 31 * result + element.hashCode()
return result
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.4")
public actual fun DoubleArray?.contentHashCode(): Int {
if (this === null) return 0
var result = 1
for (element in this)
result = 31 * result + element.hashCode()
return result
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.4")
public actual fun BooleanArray?.contentHashCode(): Int {
if (this === null) return 0
var result = 1
for (element in this)
result = 31 * result + element.hashCode()
return result
}
/**
* Returns a hash code based on the contents of this array as if it is [List].
*/
@SinceKotlin("1.4")
public actual fun CharArray?.contentHashCode(): Int {
if (this === null) return 0
var result = 1 var result = 1
for (element in this) for (element in this)
result = 31 * result + element.hashCode() result = 31 * result + element.hashCode()
@@ -527,8 +788,9 @@ public actual fun CharArray.contentHashCode(): Int {
* @sample samples.collections.Arrays.ContentOperations.contentToString * @sample samples.collections.Arrays.ContentOperations.contentToString
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual fun <T> Array<out T>.contentToString(): String { public actual fun <T> Array<out T>.contentToString(): String {
return joinToString(", ", "[", "]") return this.contentToString()
} }
/** /**
@@ -537,8 +799,9 @@ public actual fun <T> Array<out T>.contentToString(): String {
* @sample samples.collections.Arrays.ContentOperations.contentToString * @sample samples.collections.Arrays.ContentOperations.contentToString
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual fun ByteArray.contentToString(): String { public actual fun ByteArray.contentToString(): String {
return joinToString(", ", "[", "]") return this.contentToString()
} }
/** /**
@@ -547,8 +810,9 @@ public actual fun ByteArray.contentToString(): String {
* @sample samples.collections.Arrays.ContentOperations.contentToString * @sample samples.collections.Arrays.ContentOperations.contentToString
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual fun ShortArray.contentToString(): String { public actual fun ShortArray.contentToString(): String {
return joinToString(", ", "[", "]") return this.contentToString()
} }
/** /**
@@ -557,8 +821,9 @@ public actual fun ShortArray.contentToString(): String {
* @sample samples.collections.Arrays.ContentOperations.contentToString * @sample samples.collections.Arrays.ContentOperations.contentToString
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual fun IntArray.contentToString(): String { public actual fun IntArray.contentToString(): String {
return joinToString(", ", "[", "]") return this.contentToString()
} }
/** /**
@@ -567,8 +832,9 @@ public actual fun IntArray.contentToString(): String {
* @sample samples.collections.Arrays.ContentOperations.contentToString * @sample samples.collections.Arrays.ContentOperations.contentToString
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual fun LongArray.contentToString(): String { public actual fun LongArray.contentToString(): String {
return joinToString(", ", "[", "]") return this.contentToString()
} }
/** /**
@@ -577,8 +843,9 @@ public actual fun LongArray.contentToString(): String {
* @sample samples.collections.Arrays.ContentOperations.contentToString * @sample samples.collections.Arrays.ContentOperations.contentToString
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual fun FloatArray.contentToString(): String { public actual fun FloatArray.contentToString(): String {
return joinToString(", ", "[", "]") return this.contentToString()
} }
/** /**
@@ -587,8 +854,9 @@ public actual fun FloatArray.contentToString(): String {
* @sample samples.collections.Arrays.ContentOperations.contentToString * @sample samples.collections.Arrays.ContentOperations.contentToString
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual fun DoubleArray.contentToString(): String { public actual fun DoubleArray.contentToString(): String {
return joinToString(", ", "[", "]") return this.contentToString()
} }
/** /**
@@ -597,8 +865,9 @@ public actual fun DoubleArray.contentToString(): String {
* @sample samples.collections.Arrays.ContentOperations.contentToString * @sample samples.collections.Arrays.ContentOperations.contentToString
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual fun BooleanArray.contentToString(): String { public actual fun BooleanArray.contentToString(): String {
return joinToString(", ", "[", "]") return this.contentToString()
} }
/** /**
@@ -607,8 +876,99 @@ public actual fun BooleanArray.contentToString(): String {
* @sample samples.collections.Arrays.ContentOperations.contentToString * @sample samples.collections.Arrays.ContentOperations.contentToString
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.internal.LowPriorityInOverloadResolution
public actual fun CharArray.contentToString(): String { public actual fun CharArray.contentToString(): String {
return joinToString(", ", "[", "]") return this.contentToString()
}
/**
* Returns a string representation of the contents of the specified array as if it is [List].
*
* @sample samples.collections.Arrays.ContentOperations.contentToString
*/
@SinceKotlin("1.4")
public actual fun <T> Array<out T>?.contentToString(): String {
return this?.joinToString(", ", "[", "]") ?: "null"
}
/**
* Returns a string representation of the contents of the specified array as if it is [List].
*
* @sample samples.collections.Arrays.ContentOperations.contentToString
*/
@SinceKotlin("1.4")
public actual fun ByteArray?.contentToString(): String {
return this?.joinToString(", ", "[", "]") ?: "null"
}
/**
* Returns a string representation of the contents of the specified array as if it is [List].
*
* @sample samples.collections.Arrays.ContentOperations.contentToString
*/
@SinceKotlin("1.4")
public actual fun ShortArray?.contentToString(): String {
return this?.joinToString(", ", "[", "]") ?: "null"
}
/**
* Returns a string representation of the contents of the specified array as if it is [List].
*
* @sample samples.collections.Arrays.ContentOperations.contentToString
*/
@SinceKotlin("1.4")
public actual fun IntArray?.contentToString(): String {
return this?.joinToString(", ", "[", "]") ?: "null"
}
/**
* Returns a string representation of the contents of the specified array as if it is [List].
*
* @sample samples.collections.Arrays.ContentOperations.contentToString
*/
@SinceKotlin("1.4")
public actual fun LongArray?.contentToString(): String {
return this?.joinToString(", ", "[", "]") ?: "null"
}
/**
* Returns a string representation of the contents of the specified array as if it is [List].
*
* @sample samples.collections.Arrays.ContentOperations.contentToString
*/
@SinceKotlin("1.4")
public actual fun FloatArray?.contentToString(): String {
return this?.joinToString(", ", "[", "]") ?: "null"
}
/**
* Returns a string representation of the contents of the specified array as if it is [List].
*
* @sample samples.collections.Arrays.ContentOperations.contentToString
*/
@SinceKotlin("1.4")
public actual fun DoubleArray?.contentToString(): String {
return this?.joinToString(", ", "[", "]") ?: "null"
}
/**
* Returns a string representation of the contents of the specified array as if it is [List].
*
* @sample samples.collections.Arrays.ContentOperations.contentToString
*/
@SinceKotlin("1.4")
public actual fun BooleanArray?.contentToString(): String {
return this?.joinToString(", ", "[", "]") ?: "null"
}
/**
* Returns a string representation of the contents of the specified array as if it is [List].
*
* @sample samples.collections.Arrays.ContentOperations.contentToString
*/
@SinceKotlin("1.4")
public actual fun CharArray?.contentToString(): String {
return this?.joinToString(", ", "[", "]") ?: "null"
} }
/** /**
@@ -46,7 +46,8 @@ public inline fun <T> Array<out T>.subarrayContentToString(offset: Int, length:
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@UseExperimental(ExperimentalUnsignedTypes::class) @UseExperimental(ExperimentalUnsignedTypes::class)
internal fun <T> Array<out T>.contentDeepHashCodeImpl(): Int { internal fun <T> Array<out T>?.contentDeepHashCodeImpl(): Int {
if (this == null) return 0
var result = 1 var result = 1
for (element in this) { for (element in this) {
val elementHash = when (element) { val elementHash = when (element) {