[K/N] Commonize String.regionMatches function

As a part of efforts to stabilize K/N stdlib.
This commit is contained in:
Abduqodiri Qurbonzoda
2023-04-08 22:45:12 +03:00
committed by Space Team
parent 0d31b0d12c
commit 7eba68e62b
7 changed files with 74 additions and 4 deletions
@@ -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) }
/**