diff --git a/libraries/stdlib/src/generated/_Arrays.kt b/libraries/stdlib/src/generated/_Arrays.kt index 4537990c6db..79185891674 100644 --- a/libraries/stdlib/src/generated/_Arrays.kt +++ b/libraries/stdlib/src/generated/_Arrays.kt @@ -5148,6 +5148,294 @@ public fun CharArray.sortedWith(comparator: Comparator): List { return toTypedArray().apply { sortWith(comparator) }.asList() } +/** + * 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. + * + * 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. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline infix fun Array.contentDeepEquals(other: Array): Boolean { + return Arrays.deepEquals(this, other) +} + +/** + * 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. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun Array.contentDeepHashCode(): Int { + return Arrays.deepHashCode(this) +} + +/** + * Returns a string representation of the contents of this array as if it is [List]. + * + * Nested arrays are treated as lists too. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun Array.contentDeepToString(): String { + return Arrays.deepToString(this) +} + +/** + * 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. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline infix fun Array.contentEquals(other: Array): Boolean { + return Arrays.equals(this, 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. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline infix fun ByteArray.contentEquals(other: ByteArray): Boolean { + return Arrays.equals(this, 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. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline infix fun ShortArray.contentEquals(other: ShortArray): Boolean { + return Arrays.equals(this, 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. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline infix fun IntArray.contentEquals(other: IntArray): Boolean { + return Arrays.equals(this, 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. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline infix fun LongArray.contentEquals(other: LongArray): Boolean { + return Arrays.equals(this, 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. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline infix fun FloatArray.contentEquals(other: FloatArray): Boolean { + return Arrays.equals(this, 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. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline infix fun DoubleArray.contentEquals(other: DoubleArray): Boolean { + return Arrays.equals(this, 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. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline infix fun BooleanArray.contentEquals(other: BooleanArray): Boolean { + return Arrays.equals(this, 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. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline infix fun CharArray.contentEquals(other: CharArray): Boolean { + return Arrays.equals(this, other) +} + +/** + * Returns a hash code based on the contents of this array as if it is [List]. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun Array.contentHashCode(): Int { + return Arrays.hashCode(this) +} + +/** + * Returns a hash code based on the contents of this array as if it is [List]. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun ByteArray.contentHashCode(): Int { + return Arrays.hashCode(this) +} + +/** + * Returns a hash code based on the contents of this array as if it is [List]. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun ShortArray.contentHashCode(): Int { + return Arrays.hashCode(this) +} + +/** + * Returns a hash code based on the contents of this array as if it is [List]. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun IntArray.contentHashCode(): Int { + return Arrays.hashCode(this) +} + +/** + * Returns a hash code based on the contents of this array as if it is [List]. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun LongArray.contentHashCode(): Int { + return Arrays.hashCode(this) +} + +/** + * Returns a hash code based on the contents of this array as if it is [List]. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun FloatArray.contentHashCode(): Int { + return Arrays.hashCode(this) +} + +/** + * Returns a hash code based on the contents of this array as if it is [List]. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun DoubleArray.contentHashCode(): Int { + return Arrays.hashCode(this) +} + +/** + * Returns a hash code based on the contents of this array as if it is [List]. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun BooleanArray.contentHashCode(): Int { + return Arrays.hashCode(this) +} + +/** + * Returns a hash code based on the contents of this array as if it is [List]. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun CharArray.contentHashCode(): Int { + return Arrays.hashCode(this) +} + +/** + * Returns a string representation of the contents of the specified array as if it is [List]. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun Array.contentToString(): String { + return Arrays.toString(this) +} + +/** + * Returns a string representation of the contents of the specified array as if it is [List]. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun ByteArray.contentToString(): String { + return Arrays.toString(this) +} + +/** + * Returns a string representation of the contents of the specified array as if it is [List]. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun ShortArray.contentToString(): String { + return Arrays.toString(this) +} + +/** + * Returns a string representation of the contents of the specified array as if it is [List]. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun IntArray.contentToString(): String { + return Arrays.toString(this) +} + +/** + * Returns a string representation of the contents of the specified array as if it is [List]. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun LongArray.contentToString(): String { + return Arrays.toString(this) +} + +/** + * Returns a string representation of the contents of the specified array as if it is [List]. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun FloatArray.contentToString(): String { + return Arrays.toString(this) +} + +/** + * Returns a string representation of the contents of the specified array as if it is [List]. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun DoubleArray.contentToString(): String { + return Arrays.toString(this) +} + +/** + * Returns a string representation of the contents of the specified array as if it is [List]. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun BooleanArray.contentToString(): String { + return Arrays.toString(this) +} + +/** + * Returns a string representation of the contents of the specified array as if it is [List]. + */ +@kotlin.jvm.JvmVersion +@kotlin.internal.InlineOnly +public inline fun CharArray.contentToString(): String { + return Arrays.toString(this) +} + /** * Returns the range of valid indices for the array. */ diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Arrays.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Arrays.kt index fd1db835f25..fc1a91ce19f 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Arrays.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Arrays.kt @@ -44,6 +44,102 @@ fun arrays(): List { } } + templates add f("contentEquals(other: SELF)") { + only(ArraysOfObjects, ArraysOfPrimitives) + jvmOnly(true) + inline(Inline.Only) + infix(true) + doc { + """ + 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. + """ + } + returns("Boolean") + body { + "return Arrays.equals(this, other)" + } + } + + templates add f("contentDeepEquals(other: SELF)") { + only(ArraysOfObjects) + jvmOnly(true) + inline(Inline.Only) + infix(true) + doc { + """ + 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. + + 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. + """ + } + returns("Boolean") + body { + "return Arrays.deepEquals(this, other)" + } + } + + templates add f("contentToString()") { + only(ArraysOfObjects, ArraysOfPrimitives) + jvmOnly(true) + inline(Inline.Only) + doc { "Returns a string representation of the contents of the specified array as if it is [List]." } + returns("String") + body { + "return Arrays.toString(this)" + } + } + + templates add f("contentDeepToString()") { + only(ArraysOfObjects) + jvmOnly(true) + inline(Inline.Only) + doc { + """ + Returns a string representation of the contents of this array as if it is [List]. + + Nested arrays are treated as lists too. + """ + } + returns("String") + body { + "return Arrays.deepToString(this)" + } + } + + templates add f("contentHashCode()") { + only(ArraysOfObjects, ArraysOfPrimitives) + jvmOnly(true) + inline(Inline.Only) + doc { + "Returns a hash code based on the contents of this array as if it is [List]." + } + returns("Int") + body { + "return Arrays.hashCode(this)" + } + } + + templates add f("contentDeepHashCode()") { + only(ArraysOfObjects) + jvmOnly(true) + inline(Inline.Only) + doc { + """ + 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. + """ + } + returns("Int") + body { + "return Arrays.deepHashCode(this)" + } + } + templates addAll PrimitiveType.defaultPrimitives.map { primitive -> val arrayType = primitive.name + "Array" f("to$arrayType()") {