[K/N] Commonize String.regionMatches function
As a part of efforts to stabilize K/N stdlib.
This commit is contained in:
committed by
Space Team
parent
0d31b0d12c
commit
7eba68e62b
@@ -689,6 +689,9 @@ public inline fun kotlin.CharSequence.reduceRightOrNull(operation: (kotlin.Char,
|
||||
|
||||
public fun kotlin.CharSequence.regionMatches(thisOffset: kotlin.Int, other: kotlin.CharSequence, otherOffset: kotlin.Int, length: kotlin.Int, ignoreCase: kotlin.Boolean = ...): kotlin.Boolean
|
||||
|
||||
@kotlin.SinceKotlin(version = "1.9")
|
||||
public fun kotlin.String.regionMatches(thisOffset: kotlin.Int, other: kotlin.String, otherOffset: kotlin.Int, length: kotlin.Int, ignoreCase: kotlin.Boolean = ...): kotlin.Boolean
|
||||
|
||||
public fun kotlin.CharSequence.removePrefix(prefix: kotlin.CharSequence): kotlin.CharSequence
|
||||
|
||||
public fun kotlin.String.removePrefix(prefix: kotlin.CharSequence): kotlin.String
|
||||
|
||||
@@ -689,6 +689,9 @@ public inline fun kotlin.CharSequence.reduceRightOrNull(operation: (kotlin.Char,
|
||||
|
||||
public fun kotlin.CharSequence.regionMatches(thisOffset: kotlin.Int, other: kotlin.CharSequence, otherOffset: kotlin.Int, length: kotlin.Int, ignoreCase: kotlin.Boolean = ...): kotlin.Boolean
|
||||
|
||||
@kotlin.SinceKotlin(version = "1.9")
|
||||
public fun kotlin.String.regionMatches(thisOffset: kotlin.Int, other: kotlin.String, otherOffset: kotlin.Int, length: kotlin.Int, ignoreCase: kotlin.Boolean = ...): kotlin.Boolean
|
||||
|
||||
public fun kotlin.CharSequence.removePrefix(prefix: kotlin.CharSequence): kotlin.CharSequence
|
||||
|
||||
public fun kotlin.String.removePrefix(prefix: kotlin.CharSequence): kotlin.String
|
||||
|
||||
@@ -311,6 +311,22 @@ expect fun CharSequence.regionMatches(
|
||||
ignoreCase: Boolean = false
|
||||
): Boolean
|
||||
|
||||
/**
|
||||
* Returns `true` if the specified range in this string is equal to the specified range in another string.
|
||||
* @param thisOffset the start offset in this string of the substring to compare.
|
||||
* @param other the string against a substring of which the comparison is performed.
|
||||
* @param otherOffset the start offset in the other string of the substring to compare.
|
||||
* @param length the length of the substring to compare.
|
||||
*/
|
||||
@SinceKotlin("1.9")
|
||||
public expect fun String.regionMatches(
|
||||
thisOffset: Int,
|
||||
other: String,
|
||||
otherOffset: Int,
|
||||
length: Int,
|
||||
ignoreCase: Boolean = false
|
||||
): Boolean
|
||||
|
||||
|
||||
/**
|
||||
* A Comparator that orders strings ignoring character case.
|
||||
|
||||
@@ -89,9 +89,38 @@ public actual fun String?.equals(other: String?, ignoreCase: Boolean = false): B
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns `true` if the specified range in this char sequence is equal to the specified range in another char sequence.
|
||||
* @param thisOffset the start offset in this char sequence of the substring to compare.
|
||||
* @param other the string against a substring of which the comparison is performed.
|
||||
* @param otherOffset the start offset in the other char sequence of the substring to compare.
|
||||
* @param length the length of the substring to compare.
|
||||
*/
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun CharSequence.regionMatches(thisOffset: Int, other: CharSequence, otherOffset: Int, length: Int, ignoreCase: Boolean = false): Boolean =
|
||||
regionMatchesImpl(thisOffset, other, otherOffset, length, ignoreCase)
|
||||
public actual fun CharSequence.regionMatches(
|
||||
thisOffset: Int,
|
||||
other: CharSequence,
|
||||
otherOffset: Int,
|
||||
length: Int,
|
||||
ignoreCase: Boolean = false
|
||||
): Boolean = regionMatchesImpl(thisOffset, other, otherOffset, length, ignoreCase)
|
||||
|
||||
/**
|
||||
* Returns `true` if the specified range in this string is equal to the specified range in another string.
|
||||
* @param thisOffset the start offset in this string of the substring to compare.
|
||||
* @param other the string against a substring of which the comparison is performed.
|
||||
* @param otherOffset the start offset in the other string of the substring to compare.
|
||||
* @param length the length of the substring to compare.
|
||||
*/
|
||||
@SinceKotlin("1.9")
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun String.regionMatches(
|
||||
thisOffset: Int,
|
||||
other: String,
|
||||
otherOffset: Int,
|
||||
length: Int,
|
||||
ignoreCase: Boolean = false
|
||||
): Boolean = regionMatchesImpl(thisOffset, other, otherOffset, length, ignoreCase)
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -649,7 +649,8 @@ public actual fun CharSequence.regionMatches(thisOffset: Int, other: CharSequenc
|
||||
* @param otherOffset the start offset in the other string of the substring to compare.
|
||||
* @param length the length of the substring to compare.
|
||||
*/
|
||||
public fun String.regionMatches(thisOffset: Int, other: String, otherOffset: Int, length: Int, ignoreCase: Boolean = false): Boolean =
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun String.regionMatches(thisOffset: Int, other: String, otherOffset: Int, length: Int, ignoreCase: Boolean = false): Boolean =
|
||||
if (!ignoreCase)
|
||||
(this as java.lang.String).regionMatches(thisOffset, other, otherOffset, length)
|
||||
else
|
||||
|
||||
@@ -501,6 +501,23 @@ actual fun CharSequence.regionMatches(
|
||||
ignoreCase: Boolean
|
||||
): Boolean = regionMatchesImpl(thisOffset, other, otherOffset, length, ignoreCase)
|
||||
|
||||
/**
|
||||
* Returns `true` if the specified range in this string is equal to the specified range in another string.
|
||||
* @param thisOffset the start offset in this string of the substring to compare.
|
||||
* @param other the string against a substring of which the comparison is performed.
|
||||
* @param otherOffset the start offset in the other string of the substring to compare.
|
||||
* @param length the length of the substring to compare.
|
||||
*/
|
||||
@SinceKotlin("1.9")
|
||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||
public actual fun String.regionMatches(
|
||||
thisOffset: Int,
|
||||
other: String,
|
||||
otherOffset: Int,
|
||||
length: Int,
|
||||
ignoreCase: Boolean = false
|
||||
): Boolean = regionMatchesImpl(thisOffset, other, otherOffset, length, ignoreCase)
|
||||
|
||||
private val STRING_CASE_INSENSITIVE_ORDER = Comparator<String> { a, b -> a.compareTo(b, ignoreCase = true) }
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user