stdlib-jvm: move JVM specific sources, add actual modifier where required

Update copyright path after moving JVM sources
This commit is contained in:
Ilya Gorbunov
2018-01-24 21:28:17 +03:00
parent 93f7a46ba4
commit 22255a5cc4
58 changed files with 238 additions and 234 deletions
@@ -1,3 +1,8 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
@file:JvmVersion @file:JvmVersion
package kotlin.collections package kotlin.collections
@@ -1,3 +1,8 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
@file:JvmVersion @file:JvmVersion
package kotlin.collections package kotlin.collections
@@ -9,7 +14,7 @@ import java.util.AbstractList
* @param E the type of elements contained in the list. The list is invariant on its element type. * @param E the type of elements contained in the list. The list is invariant on its element type.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
public abstract class AbstractMutableList<E> protected constructor() : MutableList<E>, AbstractList<E>() { public actual abstract class AbstractMutableList<E> protected actual constructor() : MutableList<E>, AbstractList<E>() {
/** /**
* Replaces the element at the specified position in this list with the specified element. * Replaces the element at the specified position in this list with the specified element.
* *
@@ -1,3 +1,8 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
@file:JvmVersion @file:JvmVersion
package kotlin.collections package kotlin.collections
@@ -12,7 +17,7 @@ import java.util.AbstractMap
* @param V the type of map values. The map is invariant on its value type. * @param V the type of map values. The map is invariant on its value type.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
public abstract class AbstractMutableMap<K, V> protected constructor() : MutableMap<K, V>, AbstractMap<K, V>() { public actual abstract class AbstractMutableMap<K, V> protected actual constructor() : MutableMap<K, V>, AbstractMap<K, V>() {
/** /**
* Associates the specified [value] with the specified [key] in the map. * Associates the specified [value] with the specified [key] in the map.
* *
@@ -21,5 +26,5 @@ public abstract class AbstractMutableMap<K, V> protected constructor() : Mutable
* *
* @return the previous value associated with the key, or `null` if the key was not present in the map. * @return the previous value associated with the key, or `null` if the key was not present in the map.
*/ */
abstract override fun put(key: K, value: V): V? actual abstract override fun put(key: K, value: V): V?
} }
@@ -1,3 +1,8 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
@file:JvmVersion @file:JvmVersion
package kotlin.collections package kotlin.collections
@@ -9,7 +14,7 @@ import java.util.AbstractSet
* @param E the type of elements contained in the set. The set is invariant on its element type. * @param E the type of elements contained in the set. The set is invariant on its element type.
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
public abstract class AbstractMutableSet<E> protected constructor() : MutableSet<E>, AbstractSet<E>() { public actual abstract class AbstractMutableSet<E> protected actual constructor() : MutableSet<E>, AbstractSet<E>() {
/** /**
* Adds the specified element to the set. * Adds the specified element to the set.
* *
@@ -18,5 +23,5 @@ public abstract class AbstractMutableSet<E> protected constructor() : MutableSet
* *
* @return `true` if the element has been added, `false` if the element is already contained in the set. * @return `true` if the element has been added, `false` if the element is already contained in the set.
*/ */
abstract override fun add(element: E): Boolean actual abstract override fun add(element: E): Boolean
} }
@@ -1,17 +1,6 @@
/* /*
* Copyright 2010-2016 JetBrains s.r.o. * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* * that can be found in the license/LICENSE.txt file.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ */
@file:kotlin.jvm.JvmMultifileClass @file:kotlin.jvm.JvmMultifileClass
@@ -27,7 +16,7 @@ import java.nio.charset.Charset
* Returns the array if it's not `null`, or an empty array otherwise. * Returns the array if it's not `null`, or an empty array otherwise.
* @sample samples.collections.Arrays.Usage.arrayOrEmpty * @sample samples.collections.Arrays.Usage.arrayOrEmpty
*/ */
public inline fun <reified T> Array<out T>?.orEmpty(): Array<out T> = this ?: emptyArray<T>() public actual inline fun <reified T> Array<out T>?.orEmpty(): Array<out T> = this ?: emptyArray<T>()
/** /**
* Converts the contents of this byte array to a string using the specified [charset]. * Converts the contents of this byte array to a string using the specified [charset].
@@ -44,14 +33,14 @@ public inline fun ByteArray.toString(charset: Charset): String = String(this, ch
* @sample samples.collections.Collections.Collections.collectionToTypedArray * @sample samples.collections.Collections.Collections.collectionToTypedArray
*/ */
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
public inline fun <reified T> Collection<T>.toTypedArray(): Array<T> { public actual inline fun <reified T> Collection<T>.toTypedArray(): Array<T> {
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
val thisCollection = this as java.util.Collection<T> val thisCollection = this as java.util.Collection<T>
return thisCollection.toArray(arrayOfNulls<T>(0)) as Array<T> return thisCollection.toArray(arrayOfNulls<T>(0)) as Array<T>
} }
/** Internal unsafe construction of array based on reference array type */ /** Internal unsafe construction of array based on reference array type */
internal fun <T> arrayOfNulls(reference: Array<T>, size: Int): Array<T> { internal actual fun <T> arrayOfNulls(reference: Array<T>, size: Int): Array<T> {
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
return java.lang.reflect.Array.newInstance(reference.javaClass.componentType, size) as Array<T> return java.lang.reflect.Array.newInstance(reference.javaClass.componentType, size) as Array<T>
} }
@@ -31,17 +31,17 @@ public inline fun <T> java.util.Enumeration<T>.toList(): List<T> = java.util.Col
@JvmVersion @JvmVersion
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
internal inline fun copyToArrayImpl(collection: Collection<*>): Array<Any?> = internal actual inline fun copyToArrayImpl(collection: Collection<*>): Array<Any?> =
kotlin.jvm.internal.collectionToArray(collection) kotlin.jvm.internal.collectionToArray(collection)
@JvmVersion @JvmVersion
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
internal inline fun <T> copyToArrayImpl(collection: Collection<*>, array: Array<T>): Array<T> = internal actual inline fun <T> copyToArrayImpl(collection: Collection<*>, array: Array<T>): Array<T> =
kotlin.jvm.internal.collectionToArray(collection, array as Array<Any?>) as Array<T> kotlin.jvm.internal.collectionToArray(collection, array as Array<Any?>) as Array<T>
// copies typed varargs array to array of objects // copies typed varargs array to array of objects
@JvmVersion @JvmVersion
internal fun <T> Array<out T>.copyToArrayOfAny(isVarargs: Boolean): Array<Any?> = internal actual fun <T> Array<out T>.copyToArrayOfAny(isVarargs: Boolean): Array<out Any?> =
if (isVarargs && this.javaClass == Array<Any?>::class.java) if (isVarargs && this.javaClass == Array<Any?>::class.java)
// if the array came from varargs and already is array of Any, copying isn't required // if the array came from varargs and already is array of Any, copying isn't required
@Suppress("UNCHECKED_CAST") (this as Array<Any?>) @Suppress("UNCHECKED_CAST") (this as Array<Any?>)
@@ -18,7 +18,7 @@ package kotlin.collections
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@JvmVersion @JvmVersion
public fun <T, K> Grouping<T, K>.eachCount(): Map<K, Int> = public actual fun <T, K> Grouping<T, K>.eachCount(): Map<K, Int> =
// fold(0) { acc, e -> acc + 1 } optimized for boxing // fold(0) { acc, e -> acc + 1 } optimized for boxing
foldTo(destination = mutableMapOf(), foldTo(destination = mutableMapOf(),
initialValueSelector = { _, _ -> kotlin.jvm.internal.Ref.IntRef() }, initialValueSelector = { _, _ -> kotlin.jvm.internal.Ref.IntRef() },
@@ -80,10 +80,10 @@ public inline fun Map<String, String>.toProperties(): Properties
// creates a singleton copy of map, if there is specialization available in target platform, otherwise returns itself // creates a singleton copy of map, if there is specialization available in target platform, otherwise returns itself
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
internal inline fun <K, V> Map<K, V>.toSingletonMapOrSelf(): Map<K, V> = toSingletonMap() internal actual inline fun <K, V> Map<K, V>.toSingletonMapOrSelf(): Map<K, V> = toSingletonMap()
// creates a singleton copy of map // creates a singleton copy of map
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
internal fun <K, V> Map<out K, V>.toSingletonMap(): Map<K, V> internal actual fun <K, V> Map<out K, V>.toSingletonMap(): Map<K, V>
= with (entries.iterator().next()) { java.util.Collections.singletonMap(key, value) } = with (entries.iterator().next()) { java.util.Collections.singletonMap(key, value) }
@@ -26,7 +26,7 @@ public inline fun <T> MutableList<T>.sort(comparison: (T, T) -> Int): Unit = thr
* Sorts elements in the list in-place according to their natural sort order. * Sorts elements in the list in-place according to their natural sort order.
*/ */
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
public fun <T : Comparable<T>> MutableList<T>.sort(): Unit { public actual fun <T : Comparable<T>> MutableList<T>.sort(): Unit {
if (size > 1) java.util.Collections.sort(this) if (size > 1) java.util.Collections.sort(this)
} }
@@ -34,7 +34,7 @@ public fun <T : Comparable<T>> MutableList<T>.sort(): Unit {
* Sorts elements in the list in-place according to the order specified with [comparator]. * Sorts elements in the list in-place according to the order specified with [comparator].
*/ */
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
public fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>): Unit { public actual fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>): Unit {
if (size > 1) java.util.Collections.sort(this, comparator) if (size > 1) java.util.Collections.sort(this, comparator)
} }
@@ -46,7 +46,7 @@ public fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>): Unit {
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
@SinceKotlin("1.2") @SinceKotlin("1.2")
public inline fun <T> MutableList<T>.fill(value: T) { public actual inline fun <T> MutableList<T>.fill(value: T) {
java.util.Collections.fill(this, value) java.util.Collections.fill(this, value)
} }
@@ -57,7 +57,7 @@ public inline fun <T> MutableList<T>.fill(value: T) {
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
@SinceKotlin("1.2") @SinceKotlin("1.2")
public inline fun <T> MutableList<T>.shuffle() { public actual inline fun <T> MutableList<T>.shuffle() {
java.util.Collections.shuffle(this) java.util.Collections.shuffle(this)
} }
@@ -76,7 +76,7 @@ public inline fun <T> MutableList<T>.shuffle(random: java.util.Random) {
*/ */
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
@SinceKotlin("1.2") @SinceKotlin("1.2")
public fun <T> Iterable<T>.shuffled(): List<T> = toMutableList().apply { shuffle() } public actual fun <T> Iterable<T>.shuffled(): List<T> = toMutableList().apply { shuffle() }
/** /**
* Returns a new list with the elements of this list randomly shuffled * Returns a new list with the elements of this list randomly shuffled
@@ -20,10 +20,10 @@ public inline fun<T> java.util.Enumeration<T>.asSequence(): Sequence<T> = this.i
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
internal class ConstrainedOnceSequence<T>(sequence: Sequence<T>) : Sequence<T> { internal actual class ConstrainedOnceSequence<T> actual constructor(sequence: Sequence<T>) : Sequence<T> {
private val sequenceRef = java.util.concurrent.atomic.AtomicReference(sequence) private val sequenceRef = java.util.concurrent.atomic.AtomicReference(sequence)
override fun iterator(): Iterator<T> { actual override fun iterator(): Iterator<T> {
val sequence = sequenceRef.getAndSet(null) ?: throw IllegalStateException("This sequence can be consumed only once.") val sequence = sequenceRef.getAndSet(null) ?: throw IllegalStateException("This sequence can be consumed only once.")
return sequence.iterator() return sequence.iterator()
} }
@@ -0,0 +1,13 @@
@file:kotlin.jvm.JvmVersion
package kotlin.collections
@SinceKotlin("1.1") public actual typealias RandomAccess = java.util.RandomAccess
@SinceKotlin("1.1") public actual typealias ArrayList<E> = java.util.ArrayList<E>
@SinceKotlin("1.1") public actual typealias LinkedHashMap<K, V> = java.util.LinkedHashMap<K, V>
@SinceKotlin("1.1") public actual typealias HashMap<K, V> = java.util.HashMap<K, V>
@SinceKotlin("1.1") public actual typealias LinkedHashSet<E> = java.util.LinkedHashSet<E>
@SinceKotlin("1.1") public actual typealias HashSet<E> = java.util.HashSet<E>
@@ -21,16 +21,16 @@ import kotlin.*
import kotlin.coroutines.experimental.intrinsics.COROUTINE_SUSPENDED import kotlin.coroutines.experimental.intrinsics.COROUTINE_SUSPENDED
@PublishedApi @PublishedApi
internal class SafeContinuation<in T> internal actual class SafeContinuation<in T>
internal constructor( internal actual constructor(
private val delegate: Continuation<T>, private val delegate: Continuation<T>,
initialResult: Any? initialResult: Any?
) : Continuation<T> { ) : Continuation<T> {
@PublishedApi @PublishedApi
internal constructor(delegate: Continuation<T>) : this(delegate, UNDECIDED) internal actual constructor(delegate: Continuation<T>) : this(delegate, UNDECIDED)
public override val context: CoroutineContext public actual override val context: CoroutineContext
get() = delegate.context get() = delegate.context
@Volatile @Volatile
@@ -48,7 +48,7 @@ internal constructor(
private class Fail(val exception: Throwable) private class Fail(val exception: Throwable)
override fun resume(value: T) { actual override fun resume(value: T) {
while (true) { // lock-free loop while (true) { // lock-free loop
val result = this.result // atomic read val result = this.result // atomic read
when { when {
@@ -62,7 +62,7 @@ internal constructor(
} }
} }
override fun resumeWithException(exception: Throwable) { actual override fun resumeWithException(exception: Throwable) {
while (true) { // lock-free loop while (true) { // lock-free loop
val result = this.result // atomic read val result = this.result // atomic read
when { when {
@@ -77,7 +77,7 @@ internal constructor(
} }
@PublishedApi @PublishedApi
internal fun getResult(): Any? { internal actual fun getResult(): Any? {
var result = this.result // atomic read var result = this.result // atomic read
if (result === UNDECIDED) { if (result === UNDECIDED) {
if (RESULT.compareAndSet(this, UNDECIDED, COROUTINE_SUSPENDED)) return COROUTINE_SUSPENDED if (RESULT.compareAndSet(this, UNDECIDED, COROUTINE_SUSPENDED)) return COROUTINE_SUSPENDED
@@ -30,7 +30,7 @@ import kotlin.coroutines.experimental.*
@SinceKotlin("1.1") @SinceKotlin("1.1")
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun <T> (suspend () -> T).startCoroutineUninterceptedOrReturn( public actual inline fun <T> (suspend () -> T).startCoroutineUninterceptedOrReturn(
completion: Continuation<T> completion: Continuation<T>
): Any? = (this as Function1<Continuation<T>, Any?>).invoke(completion) ): Any? = (this as Function1<Continuation<T>, Any?>).invoke(completion)
@@ -44,7 +44,7 @@ public inline fun <T> (suspend () -> T).startCoroutineUninterceptedOrReturn(
@SinceKotlin("1.1") @SinceKotlin("1.1")
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun <R, T> (suspend R.() -> T).startCoroutineUninterceptedOrReturn( public actual inline fun <R, T> (suspend R.() -> T).startCoroutineUninterceptedOrReturn(
receiver: R, receiver: R,
completion: Continuation<T> completion: Continuation<T>
): Any? = (this as Function2<R, Continuation<T>, Any?>).invoke(receiver, completion) ): Any? = (this as Function2<R, Continuation<T>, Any?>).invoke(receiver, completion)
@@ -64,7 +64,7 @@ public inline fun <R, T> (suspend R.() -> T).startCoroutineUninterceptedOrReturn
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
public fun <T> (suspend () -> T).createCoroutineUnchecked( public actual fun <T> (suspend () -> T).createCoroutineUnchecked(
completion: Continuation<T> completion: Continuation<T>
): Continuation<Unit> = ): Continuation<Unit> =
if (this !is kotlin.coroutines.experimental.jvm.internal.CoroutineImpl) if (this !is kotlin.coroutines.experimental.jvm.internal.CoroutineImpl)
@@ -87,7 +87,7 @@ public fun <T> (suspend () -> T).createCoroutineUnchecked(
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
public fun <R, T> (suspend R.() -> T).createCoroutineUnchecked( public actual fun <R, T> (suspend R.() -> T).createCoroutineUnchecked(
receiver: R, receiver: R,
completion: Continuation<T> completion: Continuation<T>
): Continuation<Unit> = ): Continuation<Unit> =
@@ -13,7 +13,7 @@ import java.nio.charset.CharsetDecoder
/** Prints the given message to the standard output stream. */ /** Prints the given message to the standard output stream. */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun print(message: Any?) { public actual inline fun print(message: Any?) {
System.out.print(message) System.out.print(message)
} }
@@ -73,7 +73,7 @@ public inline fun print(message: CharArray) {
/** Prints the given message and newline to the standard output stream. */ /** Prints the given message and newline to the standard output stream. */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun println(message: Any?) { public actual inline fun println(message: Any?) {
System.out.println(message) System.out.println(message)
} }
@@ -133,7 +133,7 @@ public inline fun println(message: CharArray) {
/** Prints a newline to the standard output stream. */ /** Prints a newline to the standard output stream. */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun println() { public actual inline fun println() {
System.out.println() System.out.println()
} }
@@ -17,4 +17,5 @@
package kotlin.io package kotlin.io
// to use in shared code without imports // to use in shared code without imports
internal typealias Serializable = java.io.Serializable @Suppress("ACTUAL_WITHOUT_EXPECT") // internal expect is not matched with internal typealias to public type
internal actual typealias Serializable = java.io.Serializable
@@ -76,7 +76,7 @@ public inline fun Char.isJavaIdentifierStart(): Boolean = Character.isJavaIdenti
* Determines whether a character is whitespace according to the Unicode standard. * Determines whether a character is whitespace according to the Unicode standard.
* Returns `true` if the character is whitespace. * Returns `true` if the character is whitespace.
*/ */
public fun Char.isWhitespace(): Boolean = Character.isWhitespace(this) || Character.isSpaceChar(this) public actual fun Char.isWhitespace(): Boolean = Character.isWhitespace(this) || Character.isSpaceChar(this)
/** /**
* Returns `true` if this character is upper case. * Returns `true` if this character is upper case.
@@ -94,13 +94,13 @@ public inline fun Char.isLowerCase(): Boolean = Character.isLowerCase(this)
* Converts this character to uppercase. * Converts this character to uppercase.
*/ */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun Char.toUpperCase(): Char = Character.toUpperCase(this) public actual inline fun Char.toUpperCase(): Char = Character.toUpperCase(this)
/** /**
* Converts this character to lowercase. * Converts this character to lowercase.
*/ */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun Char.toLowerCase(): Char = Character.toLowerCase(this) public actual inline fun Char.toLowerCase(): Char = Character.toLowerCase(this)
/** /**
* Returns `true` if this character is a titlecase character. * Returns `true` if this character is a titlecase character.
@@ -130,13 +130,13 @@ public val Char.directionality: CharDirectionality get() = CharDirectionality.va
* Returns `true` if this character is a Unicode high-surrogate code unit (also known as leading-surrogate code unit). * Returns `true` if this character is a Unicode high-surrogate code unit (also known as leading-surrogate code unit).
*/ */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun Char.isHighSurrogate(): Boolean = Character.isHighSurrogate(this) public actual inline fun Char.isHighSurrogate(): Boolean = Character.isHighSurrogate(this)
/** /**
* Returns `true` if this character is a Unicode low-surrogate code unit (also known as trailing-surrogate code unit). * Returns `true` if this character is a Unicode low-surrogate code unit (also known as trailing-surrogate code unit).
*/ */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun Char.isLowSurrogate(): Boolean = Character.isLowSurrogate(this) public actual inline fun Char.isLowSurrogate(): Boolean = Character.isLowSurrogate(this)
// TODO Provide name for JVM7+ // TODO Provide name for JVM7+
///** ///**
@@ -146,13 +146,13 @@ public inline fun Char.isLowSurrogate(): Boolean = Character.isLowSurrogate(this
internal fun digitOf(char: Char, radix: Int): Int = Character.digit(char.toInt(), radix) internal actual fun digitOf(char: Char, radix: Int): Int = Character.digit(char.toInt(), radix)
/** /**
* Checks whether the given [radix] is valid radix for string to number and number to string conversion. * Checks whether the given [radix] is valid radix for string to number and number to string conversion.
*/ */
@PublishedApi @PublishedApi
internal fun checkRadix(radix: Int): Int { internal actual fun checkRadix(radix: Int): Int {
if(radix !in Character.MIN_RADIX..Character.MAX_RADIX) { if(radix !in Character.MIN_RADIX..Character.MAX_RADIX) {
throw IllegalArgumentException("radix $radix was not in valid range ${Character.MIN_RADIX..Character.MAX_RADIX}") throw IllegalArgumentException("radix $radix was not in valid range ${Character.MIN_RADIX..Character.MAX_RADIX}")
} }
@@ -57,7 +57,7 @@ public inline fun Long.toString(radix: Int): String = java.lang.Long.toString(th
*/ */
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun String.toBoolean(): Boolean = java.lang.Boolean.parseBoolean(this) public actual inline fun String.toBoolean(): Boolean = java.lang.Boolean.parseBoolean(this)
/** /**
* Parses the string as a signed [Byte] number and returns the result. * Parses the string as a signed [Byte] number and returns the result.
@@ -65,7 +65,7 @@ public inline fun String.toBoolean(): Boolean = java.lang.Boolean.parseBoolean(t
*/ */
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun String.toByte(): Byte = java.lang.Byte.parseByte(this) public actual inline fun String.toByte(): Byte = java.lang.Byte.parseByte(this)
/** /**
* Parses the string as a signed [Byte] number and returns the result. * Parses the string as a signed [Byte] number and returns the result.
@@ -75,7 +75,7 @@ public inline fun String.toByte(): Byte = java.lang.Byte.parseByte(this)
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun String.toByte(radix: Int): Byte = java.lang.Byte.parseByte(this, checkRadix(radix)) public actual inline fun String.toByte(radix: Int): Byte = java.lang.Byte.parseByte(this, checkRadix(radix))
/** /**
@@ -84,7 +84,7 @@ public inline fun String.toByte(radix: Int): Byte = java.lang.Byte.parseByte(thi
*/ */
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun String.toShort(): Short = java.lang.Short.parseShort(this) public actual inline fun String.toShort(): Short = java.lang.Short.parseShort(this)
/** /**
* Parses the string as a [Short] number and returns the result. * Parses the string as a [Short] number and returns the result.
@@ -94,7 +94,7 @@ public inline fun String.toShort(): Short = java.lang.Short.parseShort(this)
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun String.toShort(radix: Int): Short = java.lang.Short.parseShort(this, checkRadix(radix)) public actual inline fun String.toShort(radix: Int): Short = java.lang.Short.parseShort(this, checkRadix(radix))
/** /**
* Parses the string as an [Int] number and returns the result. * Parses the string as an [Int] number and returns the result.
@@ -102,7 +102,7 @@ public inline fun String.toShort(radix: Int): Short = java.lang.Short.parseShort
*/ */
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun String.toInt(): Int = java.lang.Integer.parseInt(this) public actual inline fun String.toInt(): Int = java.lang.Integer.parseInt(this)
/** /**
* Parses the string as an [Int] number and returns the result. * Parses the string as an [Int] number and returns the result.
@@ -112,7 +112,7 @@ public inline fun String.toInt(): Int = java.lang.Integer.parseInt(this)
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun String.toInt(radix: Int): Int = java.lang.Integer.parseInt(this, checkRadix(radix)) public actual inline fun String.toInt(radix: Int): Int = java.lang.Integer.parseInt(this, checkRadix(radix))
/** /**
* Parses the string as a [Long] number and returns the result. * Parses the string as a [Long] number and returns the result.
@@ -120,7 +120,7 @@ public inline fun String.toInt(radix: Int): Int = java.lang.Integer.parseInt(thi
*/ */
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun String.toLong(): Long = java.lang.Long.parseLong(this) public actual inline fun String.toLong(): Long = java.lang.Long.parseLong(this)
/** /**
* Parses the string as a [Long] number and returns the result. * Parses the string as a [Long] number and returns the result.
@@ -130,7 +130,7 @@ public inline fun String.toLong(): Long = java.lang.Long.parseLong(this)
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun String.toLong(radix: Int): Long = java.lang.Long.parseLong(this, checkRadix(radix)) public actual inline fun String.toLong(radix: Int): Long = java.lang.Long.parseLong(this, checkRadix(radix))
/** /**
* Parses the string as a [Float] number and returns the result. * Parses the string as a [Float] number and returns the result.
@@ -138,7 +138,7 @@ public inline fun String.toLong(radix: Int): Long = java.lang.Long.parseLong(thi
*/ */
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun String.toFloat(): Float = java.lang.Float.parseFloat(this) public actual inline fun String.toFloat(): Float = java.lang.Float.parseFloat(this)
/** /**
* Parses the string as a [Double] number and returns the result. * Parses the string as a [Double] number and returns the result.
@@ -146,7 +146,7 @@ public inline fun String.toFloat(): Float = java.lang.Float.parseFloat(this)
*/ */
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun String.toDouble(): Double = java.lang.Double.parseDouble(this) public actual inline fun String.toDouble(): Double = java.lang.Double.parseDouble(this)
/** /**
@@ -155,7 +155,7 @@ public inline fun String.toDouble(): Double = java.lang.Double.parseDouble(this)
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
public fun String.toFloatOrNull(): Float? = screenFloatValue(this, java.lang.Float::parseFloat) public actual fun String.toFloatOrNull(): Float? = screenFloatValue(this, java.lang.Float::parseFloat)
/** /**
* Parses the string as a [Double] number and returns the result * Parses the string as a [Double] number and returns the result
@@ -163,7 +163,7 @@ public fun String.toFloatOrNull(): Float? = screenFloatValue(this, java.lang.Flo
*/ */
@SinceKotlin("1.1") @SinceKotlin("1.1")
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
public fun String.toDoubleOrNull(): Double? = screenFloatValue(this, java.lang.Double::parseDouble) public actual fun String.toDoubleOrNull(): Double? = screenFloatValue(this, java.lang.Double::parseDouble)
/** /**
* Parses the string as a [java.math.BigInteger] number and returns the result. * Parses the string as a [java.math.BigInteger] number and returns the result.
@@ -14,32 +14,32 @@ import java.util.regex.Pattern
* Returns the index within this string of the first occurrence of the specified character, starting from the specified offset. * Returns the index within this string of the first occurrence of the specified character, starting from the specified offset.
*/ */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
internal inline fun String.nativeIndexOf(ch: Char, fromIndex: Int): Int = (this as java.lang.String).indexOf(ch.toInt(), fromIndex) internal actual inline fun String.nativeIndexOf(ch: Char, fromIndex: Int): Int = (this as java.lang.String).indexOf(ch.toInt(), fromIndex)
/** /**
* Returns the index within this string of the first occurrence of the specified substring, starting from the specified offset. * Returns the index within this string of the first occurrence of the specified substring, starting from the specified offset.
*/ */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
internal inline fun String.nativeIndexOf(str: String, fromIndex: Int): Int = (this as java.lang.String).indexOf(str, fromIndex) internal actual inline fun String.nativeIndexOf(str: String, fromIndex: Int): Int = (this as java.lang.String).indexOf(str, fromIndex)
/** /**
* Returns the index within this string of the last occurrence of the specified character. * Returns the index within this string of the last occurrence of the specified character.
*/ */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
internal inline fun String.nativeLastIndexOf(ch: Char, fromIndex: Int): Int = (this as java.lang.String).lastIndexOf(ch.toInt(), fromIndex) internal actual inline fun String.nativeLastIndexOf(ch: Char, fromIndex: Int): Int = (this as java.lang.String).lastIndexOf(ch.toInt(), fromIndex)
/** /**
* Returns the index within this string of the last occurrence of the specified character, starting from the specified offset. * Returns the index within this string of the last occurrence of the specified character, starting from the specified offset.
*/ */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
internal inline fun String.nativeLastIndexOf(str: String, fromIndex: Int): Int = (this as java.lang.String).lastIndexOf(str, fromIndex) internal actual inline fun String.nativeLastIndexOf(str: String, fromIndex: Int): Int = (this as java.lang.String).lastIndexOf(str, fromIndex)
/** /**
* Returns `true` if this string is equal to [other], optionally ignoring character case. * Returns `true` if this string is equal to [other], optionally ignoring character case.
* *
* @param ignoreCase `true` to ignore character case when comparing strings. By default `false`. * @param ignoreCase `true` to ignore character case when comparing strings. By default `false`.
*/ */
public fun String?.equals(other: String?, ignoreCase: Boolean = false): Boolean { public actual fun String?.equals(other: String?, ignoreCase: Boolean = false): Boolean {
if (this === null) if (this === null)
return other === null return other === null
return if (!ignoreCase) return if (!ignoreCase)
@@ -51,7 +51,7 @@ public fun String?.equals(other: String?, ignoreCase: Boolean = false): Boolean
/** /**
* Returns a new string with all occurrences of [oldChar] replaced with [newChar]. * Returns a new string with all occurrences of [oldChar] replaced with [newChar].
*/ */
public fun String.replace(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String { public actual fun String.replace(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String {
if (!ignoreCase) if (!ignoreCase)
return (this as java.lang.String).replace(oldChar, newChar) return (this as java.lang.String).replace(oldChar, newChar)
else else
@@ -62,14 +62,14 @@ public fun String.replace(oldChar: Char, newChar: Char, ignoreCase: Boolean = fa
* Returns a new string obtained by replacing all occurrences of the [oldValue] substring in this string * Returns a new string obtained by replacing all occurrences of the [oldValue] substring in this string
* with the specified [newValue] string. * with the specified [newValue] string.
*/ */
public fun String.replace(oldValue: String, newValue: String, ignoreCase: Boolean = false): String = public actual fun String.replace(oldValue: String, newValue: String, ignoreCase: Boolean = false): String =
splitToSequence(oldValue, ignoreCase = ignoreCase).joinToString(separator = newValue) splitToSequence(oldValue, ignoreCase = ignoreCase).joinToString(separator = newValue)
/** /**
* Returns a new string with the first occurrence of [oldChar] replaced with [newChar]. * Returns a new string with the first occurrence of [oldChar] replaced with [newChar].
*/ */
public fun String.replaceFirst(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String { public actual fun String.replaceFirst(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String {
val index = indexOf(oldChar, ignoreCase = ignoreCase) val index = indexOf(oldChar, ignoreCase = ignoreCase)
return if (index < 0) this else this.replaceRange(index, index + 1, newChar.toString()) return if (index < 0) this else this.replaceRange(index, index + 1, newChar.toString())
} }
@@ -78,7 +78,7 @@ public fun String.replaceFirst(oldChar: Char, newChar: Char, ignoreCase: Boolean
* Returns a new string obtained by replacing the first occurrence of the [oldValue] substring in this string * Returns a new string obtained by replacing the first occurrence of the [oldValue] substring in this string
* with the specified [newValue] string. * with the specified [newValue] string.
*/ */
public fun String.replaceFirst(oldValue: String, newValue: String, ignoreCase: Boolean = false): String { public actual fun String.replaceFirst(oldValue: String, newValue: String, ignoreCase: Boolean = false): String {
val index = indexOf(oldValue, ignoreCase = ignoreCase) val index = indexOf(oldValue, ignoreCase = ignoreCase)
return if (index < 0) this else this.replaceRange(index, index + oldValue.length, newValue) return if (index < 0) this else this.replaceRange(index, index + oldValue.length, newValue)
} }
@@ -87,13 +87,13 @@ public fun String.replaceFirst(oldValue: String, newValue: String, ignoreCase: B
* Returns a copy of this string converted to upper case using the rules of the default locale. * Returns a copy of this string converted to upper case using the rules of the default locale.
*/ */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun String.toUpperCase(): String = (this as java.lang.String).toUpperCase() public actual inline fun String.toUpperCase(): String = (this as java.lang.String).toUpperCase()
/** /**
* Returns a copy of this string converted to lower case using the rules of the default locale. * Returns a copy of this string converted to lower case using the rules of the default locale.
*/ */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun String.toLowerCase(): String = (this as java.lang.String).toLowerCase() public actual inline fun String.toLowerCase(): String = (this as java.lang.String).toLowerCase()
/** /**
* Returns a new character array containing the characters from this string. * Returns a new character array containing the characters from this string.
@@ -159,7 +159,7 @@ public fun CharSequence.split(regex: Pattern, limit: Int = 0): List<String>
* Returns a substring of this string that starts at the specified [startIndex] and continues to the end of the string. * Returns a substring of this string that starts at the specified [startIndex] and continues to the end of the string.
*/ */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun String.substring(startIndex: Int): String = (this as java.lang.String).substring(startIndex) public actual inline fun String.substring(startIndex: Int): String = (this as java.lang.String).substring(startIndex)
/** /**
* Returns the substring of this string starting at the [startIndex] and ending right before the [endIndex]. * Returns the substring of this string starting at the [startIndex] and ending right before the [endIndex].
@@ -168,7 +168,7 @@ public inline fun String.substring(startIndex: Int): String = (this as java.lang
* @param endIndex the end index (exclusive). * @param endIndex the end index (exclusive).
*/ */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun String.substring(startIndex: Int, endIndex: Int): String = (this as java.lang.String).substring(startIndex, endIndex) public actual inline fun String.substring(startIndex: Int, endIndex: Int): String = (this as java.lang.String).substring(startIndex, endIndex)
/** /**
* Returns `true` if this string starts with the specified prefix. * Returns `true` if this string starts with the specified prefix.
@@ -318,7 +318,7 @@ public inline fun String.intern(): String = (this as java.lang.String).intern()
/** /**
* Returns `true` if this string is empty or consists solely of whitespace characters. * Returns `true` if this string is empty or consists solely of whitespace characters.
*/ */
public fun CharSequence.isBlank(): Boolean = length == 0 || indices.all { this[it].isWhitespace() } public actual fun CharSequence.isBlank(): Boolean = length == 0 || indices.all { this[it].isWhitespace() }
/** /**
* Returns the index within this string that is offset from the given [index] by [codePointOffset] code points. * Returns the index within this string that is offset from the given [index] by [codePointOffset] code points.
@@ -333,7 +333,7 @@ public inline fun String.offsetByCodePoints(index: Int, codePointOffset: Int): I
* @param otherOffset the start offset in the other char sequence of the substring to compare. * @param otherOffset the start offset in the other char sequence of the substring to compare.
* @param length the length of the substring to compare. * @param length the length of the substring to compare.
*/ */
public fun CharSequence.regionMatches(thisOffset: Int, other: CharSequence, otherOffset: Int, length: Int, ignoreCase: Boolean = false): Boolean { public actual fun CharSequence.regionMatches(thisOffset: Int, other: CharSequence, otherOffset: Int, length: Int, ignoreCase: Boolean = false): Boolean {
if (this is String && other is String) if (this is String && other is String)
return this.regionMatches(thisOffset, other, otherOffset, length, ignoreCase) return this.regionMatches(thisOffset, other, otherOffset, length, ignoreCase)
else else
@@ -388,7 +388,7 @@ public inline fun String.toPattern(flags: Int = 0): java.util.regex.Pattern {
* *
* @sample samples.text.Strings.capitalize * @sample samples.text.Strings.capitalize
*/ */
public fun String.capitalize(): String { public actual fun String.capitalize(): String {
return if (isNotEmpty() && this[0].isLowerCase()) substring(0, 1).toUpperCase() + substring(1) else this return if (isNotEmpty() && this[0].isLowerCase()) substring(0, 1).toUpperCase() + substring(1) else this
} }
@@ -398,7 +398,7 @@ public fun String.capitalize(): String {
* *
* @sample samples.text.Strings.decapitalize * @sample samples.text.Strings.decapitalize
*/ */
public fun String.decapitalize(): String { public actual fun String.decapitalize(): String {
return if (isNotEmpty() && this[0].isUpperCase()) substring(0, 1).toLowerCase() + substring(1) else this return if (isNotEmpty() && this[0].isUpperCase()) substring(0, 1).toLowerCase() + substring(1) else this
} }
@@ -407,7 +407,7 @@ public fun String.decapitalize(): String {
* @throws [IllegalArgumentException] when n < 0. * @throws [IllegalArgumentException] when n < 0.
* @sample samples.text.Strings.repeat * @sample samples.text.Strings.repeat
*/ */
public fun CharSequence.repeat(n: Int): String { public actual fun CharSequence.repeat(n: Int): String {
require (n >= 0) { "Count 'n' must be non-negative, but was $n." } require (n >= 0) { "Count 'n' must be non-negative, but was $n." }
return when (n) { return when (n) {
@@ -36,7 +36,7 @@ private inline fun <reified T> fromInt(value: Int): Set<T> where T : FlagEnum, T
/** /**
* Provides enumeration values to use to set regular expression options. * Provides enumeration values to use to set regular expression options.
*/ */
public enum class RegexOption(override val value: Int, override val mask: Int = value) : FlagEnum { public actual enum class RegexOption(override val value: Int, override val mask: Int = value) : FlagEnum {
// common // common
/** Enables case-insensitive matching. Case comparison is Unicode-aware. */ /** Enables case-insensitive matching. Case comparison is Unicode-aware. */
@@ -86,41 +86,41 @@ public enum class RegexOption(override val value: Int, override val mask: Int =
* *
* The [range] property is available on JVM only. * The [range] property is available on JVM only.
*/ */
public data class MatchGroup(public val value: String, public val range: IntRange) public actual data class MatchGroup(public actual val value: String, public val range: IntRange)
/** /**
* Represents an immutable regular expression. * Represents an immutable regular expression.
* *
* For pattern syntax reference see [Pattern] * For pattern syntax reference see [Pattern]
*/ */
public class Regex public actual class Regex
@PublishedApi @PublishedApi
internal constructor(private val nativePattern: Pattern) : Serializable { internal constructor(private val nativePattern: Pattern) : Serializable {
/** Creates a regular expression from the specified [pattern] string and the default options. */ /** Creates a regular expression from the specified [pattern] string and the default options. */
public constructor(pattern: String): this(Pattern.compile(pattern)) public actual constructor(pattern: String): this(Pattern.compile(pattern))
/** Creates a regular expression from the specified [pattern] string and the specified single [option]. */ /** Creates a regular expression from the specified [pattern] string and the specified single [option]. */
public constructor(pattern: String, option: RegexOption): this(Pattern.compile(pattern, ensureUnicodeCase(option.value))) public actual constructor(pattern: String, option: RegexOption): this(Pattern.compile(pattern, ensureUnicodeCase(option.value)))
/** Creates a regular expression from the specified [pattern] string and the specified set of [options]. */ /** Creates a regular expression from the specified [pattern] string and the specified set of [options]. */
public constructor(pattern: String, options: Set<RegexOption>): this(Pattern.compile(pattern, ensureUnicodeCase(options.toInt()))) public actual constructor(pattern: String, options: Set<RegexOption>): this(Pattern.compile(pattern, ensureUnicodeCase(options.toInt())))
/** The pattern string of this regular expression. */ /** The pattern string of this regular expression. */
public val pattern: String public actual val pattern: String
get() = nativePattern.pattern() get() = nativePattern.pattern()
private var _options: Set<RegexOption>? = null private var _options: Set<RegexOption>? = null
/** The set of options that were used to create this regular expression. */ /** The set of options that were used to create this regular expression. */
public val options: Set<RegexOption> get() = _options ?: fromInt<RegexOption>(nativePattern.flags()).also { _options = it } public actual val options: Set<RegexOption> get() = _options ?: fromInt<RegexOption>(nativePattern.flags()).also { _options = it }
/** Indicates whether the regular expression matches the entire [input]. */ /** Indicates whether the regular expression matches the entire [input]. */
public infix fun matches(input: CharSequence): Boolean = nativePattern.matcher(input).matches() public actual infix fun matches(input: CharSequence): Boolean = nativePattern.matcher(input).matches()
/** Indicates whether the regular expression can find at least one match in the specified [input]. */ /** Indicates whether the regular expression can find at least one match in the specified [input]. */
public fun containsMatchIn(input: CharSequence): Boolean = nativePattern.matcher(input).find() public actual fun containsMatchIn(input: CharSequence): Boolean = nativePattern.matcher(input).find()
/** /**
* Returns the first match of a regular expression in the [input], beginning at the specified [startIndex]. * Returns the first match of a regular expression in the [input], beginning at the specified [startIndex].
@@ -128,33 +128,33 @@ internal constructor(private val nativePattern: Pattern) : Serializable {
* @param startIndex An index to start search with, by default 0. Must be not less than zero and not greater than `input.length()` * @param startIndex An index to start search with, by default 0. Must be not less than zero and not greater than `input.length()`
* @return An instance of [MatchResult] if match was found or `null` otherwise. * @return An instance of [MatchResult] if match was found or `null` otherwise.
*/ */
public fun find(input: CharSequence, startIndex: Int = 0): MatchResult? = nativePattern.matcher(input).findNext(startIndex, input) public actual fun find(input: CharSequence, startIndex: Int = 0): MatchResult? = nativePattern.matcher(input).findNext(startIndex, input)
/** /**
* Returns a sequence of all occurrences of a regular expression within the [input] string, beginning at the specified [startIndex]. * Returns a sequence of all occurrences of a regular expression within the [input] string, beginning at the specified [startIndex].
*/ */
public fun findAll(input: CharSequence, startIndex: Int = 0): Sequence<MatchResult> = generateSequence({ find(input, startIndex) }, MatchResult::next) public actual fun findAll(input: CharSequence, startIndex: Int = 0): Sequence<MatchResult> = generateSequence({ find(input, startIndex) }, MatchResult::next)
/** /**
* Attempts to match the entire [input] CharSequence against the pattern. * Attempts to match the entire [input] CharSequence against the pattern.
* *
* @return An instance of [MatchResult] if the entire input matches or `null` otherwise. * @return An instance of [MatchResult] if the entire input matches or `null` otherwise.
*/ */
public fun matchEntire(input: CharSequence): MatchResult? = nativePattern.matcher(input).matchEntire(input) public actual fun matchEntire(input: CharSequence): MatchResult? = nativePattern.matcher(input).matchEntire(input)
/** /**
* Replaces all occurrences of this regular expression in the specified [input] string with specified [replacement] expression. * Replaces all occurrences of this regular expression in the specified [input] string with specified [replacement] expression.
* *
* @param replacement A replacement expression that can include substitutions. See [Matcher.appendReplacement] for details. * @param replacement A replacement expression that can include substitutions. See [Matcher.appendReplacement] for details.
*/ */
public fun replace(input: CharSequence, replacement: String): String = nativePattern.matcher(input).replaceAll(replacement) public actual fun replace(input: CharSequence, replacement: String): String = nativePattern.matcher(input).replaceAll(replacement)
/** /**
* Replaces all occurrences of this regular expression in the specified [input] string with the result of * Replaces all occurrences of this regular expression in the specified [input] string with the result of
* the given function [transform] that takes [MatchResult] and returns a string to be used as a * the given function [transform] that takes [MatchResult] and returns a string to be used as a
* replacement for that match. * replacement for that match.
*/ */
public fun replace(input: CharSequence, transform: (MatchResult) -> CharSequence): String { public actual fun replace(input: CharSequence, transform: (MatchResult) -> CharSequence): String {
var match: MatchResult? = find(input) ?: return input.toString() var match: MatchResult? = find(input) ?: return input.toString()
var lastStart = 0 var lastStart = 0
@@ -180,7 +180,7 @@ internal constructor(private val nativePattern: Pattern) : Serializable {
* *
* @param replacement A replacement expression that can include substitutions. See [Matcher.appendReplacement] for details. * @param replacement A replacement expression that can include substitutions. See [Matcher.appendReplacement] for details.
*/ */
public fun replaceFirst(input: CharSequence, replacement: String): String = nativePattern.matcher(input).replaceFirst(replacement) public actual fun replaceFirst(input: CharSequence, replacement: String): String = nativePattern.matcher(input).replaceFirst(replacement)
/** /**
@@ -189,7 +189,7 @@ internal constructor(private val nativePattern: Pattern) : Serializable {
* @param limit Non-negative value specifying the maximum number of substrings the string can be split to. * @param limit Non-negative value specifying the maximum number of substrings the string can be split to.
* Zero by default means no limit is set. * Zero by default means no limit is set.
*/ */
public fun split(input: CharSequence, limit: Int = 0): List<String> { public actual fun split(input: CharSequence, limit: Int = 0): List<String> {
require(limit >= 0, { "Limit must be non-negative, but was $limit." } ) require(limit >= 0, { "Limit must be non-negative, but was $limit." } )
return nativePattern.split(input, if (limit == 0) -1 else limit).asList() return nativePattern.split(input, if (limit == 0) -1 else limit).asList()
} }
@@ -214,13 +214,13 @@ internal constructor(private val nativePattern: Pattern) : Serializable {
private fun readResolve(): Any = Regex(Pattern.compile(pattern, flags)) private fun readResolve(): Any = Regex(Pattern.compile(pattern, flags))
} }
companion object { actual companion object {
/** Returns a literal regex for the specified [literal] string. */ /** Returns a literal regex for the specified [literal] string. */
public fun fromLiteral(literal: String): Regex = literal.toRegex(RegexOption.LITERAL) public actual fun fromLiteral(literal: String): Regex = literal.toRegex(RegexOption.LITERAL)
/** Returns a literal pattern for the specified [literal] string. */ /** Returns a literal pattern for the specified [literal] string. */
public fun escape(literal: String): String = Pattern.quote(literal) public actual fun escape(literal: String): String = Pattern.quote(literal)
/** Returns a literal replacement expression for the specified [literal] string. */ /** Returns a literal replacement expression for the specified [literal] string. */
public fun escapeReplacement(literal: String): String = Matcher.quoteReplacement(literal) public actual fun escapeReplacement(literal: String): String = Matcher.quoteReplacement(literal)
private fun ensureUnicodeCase(flags: Int) = if (flags and Pattern.CASE_INSENSITIVE != 0) flags or Pattern.UNICODE_CASE else flags private fun ensureUnicodeCase(flags: Int) = if (flags and Pattern.CASE_INSENSITIVE != 0) flags or Pattern.UNICODE_CASE else flags
} }
@@ -19,7 +19,7 @@ package kotlin
* the returned instance as it may cause accidental deadlock. Also this behavior can be changed in the future. * the returned instance as it may cause accidental deadlock. Also this behavior can be changed in the future.
*/ */
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
public fun <T> lazy(initializer: () -> T): Lazy<T> = SynchronizedLazyImpl(initializer) public actual fun <T> lazy(initializer: () -> T): Lazy<T> = SynchronizedLazyImpl(initializer)
/** /**
* Creates a new instance of the [Lazy] that uses the specified initialization function [initializer] * Creates a new instance of the [Lazy] that uses the specified initialization function [initializer]
@@ -32,7 +32,7 @@ public fun <T> lazy(initializer: () -> T): Lazy<T> = SynchronizedLazyImpl(initia
* Also this behavior can be changed in the future. * Also this behavior can be changed in the future.
*/ */
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
public fun <T> lazy(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy<T> = public actual fun <T> lazy(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy<T> =
when (mode) { when (mode) {
LazyThreadSafetyMode.SYNCHRONIZED -> SynchronizedLazyImpl(initializer) LazyThreadSafetyMode.SYNCHRONIZED -> SynchronizedLazyImpl(initializer)
LazyThreadSafetyMode.PUBLICATION -> SafePublicationLazyImpl(initializer) LazyThreadSafetyMode.PUBLICATION -> SafePublicationLazyImpl(initializer)
@@ -51,7 +51,7 @@ public fun <T> lazy(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy<T> =
* Also this behavior can be changed in the future. * Also this behavior can be changed in the future.
*/ */
@kotlin.jvm.JvmVersion @kotlin.jvm.JvmVersion
public fun <T> lazy(lock: Any?, initializer: () -> T): Lazy<T> = SynchronizedLazyImpl(initializer, lock) public actual fun <T> lazy(lock: Any?, initializer: () -> T): Lazy<T> = SynchronizedLazyImpl(initializer, lock)
@@ -24,12 +24,6 @@ import kotlin.internal.InlineOnly
import java.lang.Math as nativeMath import java.lang.Math as nativeMath
// constants // constants
/** Ratio of the circumference of a circle to its diameter, approximately 3.14159. */
@SinceKotlin("1.2")
public const val PI: Double = nativeMath.PI
/** Base of the natural logarithms, approximately 2.71828. */
@SinceKotlin("1.2")
public const val E: Double = nativeMath.E
/** Natural logarithm of 2.0, used to compute [log2] function */ /** Natural logarithm of 2.0, used to compute [log2] function */
private val LN2: Double = ln(2.0) private val LN2: Double = ln(2.0)
@@ -48,7 +42,7 @@ private val upper_taylor_n_bound = 1 / taylor_n_bound
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun sin(x: Double): Double = nativeMath.sin(x) public actual inline fun sin(x: Double): Double = nativeMath.sin(x)
/** Computes the cosine of the angle [x] given in radians. /** Computes the cosine of the angle [x] given in radians.
* *
@@ -57,7 +51,7 @@ public inline fun sin(x: Double): Double = nativeMath.sin(x)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun cos(x: Double): Double = nativeMath.cos(x) public actual inline fun cos(x: Double): Double = nativeMath.cos(x)
/** Computes the tangent of the angle [x] given in radians. /** Computes the tangent of the angle [x] given in radians.
* *
@@ -66,7 +60,7 @@ public inline fun cos(x: Double): Double = nativeMath.cos(x)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun tan(x: Double): Double = nativeMath.tan(x) public actual inline fun tan(x: Double): Double = nativeMath.tan(x)
/** /**
* Computes the arc sine of the value [x]; * Computes the arc sine of the value [x];
@@ -77,7 +71,7 @@ public inline fun tan(x: Double): Double = nativeMath.tan(x)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun asin(x: Double): Double = nativeMath.asin(x) public actual inline fun asin(x: Double): Double = nativeMath.asin(x)
/** /**
* Computes the arc cosine of the value [x]; * Computes the arc cosine of the value [x];
@@ -88,7 +82,7 @@ public inline fun asin(x: Double): Double = nativeMath.asin(x)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun acos(x: Double): Double = nativeMath.acos(x) public actual inline fun acos(x: Double): Double = nativeMath.acos(x)
/** /**
* Computes the arc tangent of the value [x]; * Computes the arc tangent of the value [x];
@@ -99,7 +93,7 @@ public inline fun acos(x: Double): Double = nativeMath.acos(x)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun atan(x: Double): Double = nativeMath.atan(x) public actual inline fun atan(x: Double): Double = nativeMath.atan(x)
/** /**
* Returns the angle `theta` of the polar coordinates `(r, theta)` that correspond * Returns the angle `theta` of the polar coordinates `(r, theta)` that correspond
@@ -119,7 +113,7 @@ public inline fun atan(x: Double): Double = nativeMath.atan(x)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun atan2(y: Double, x: Double): Double = nativeMath.atan2(y, x) public actual inline fun atan2(y: Double, x: Double): Double = nativeMath.atan2(y, x)
/** /**
* Computes the hyperbolic sine of the value [x]. * Computes the hyperbolic sine of the value [x].
@@ -131,7 +125,7 @@ public inline fun atan2(y: Double, x: Double): Double = nativeMath.atan2(y, x)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun sinh(x: Double): Double = nativeMath.sinh(x) public actual inline fun sinh(x: Double): Double = nativeMath.sinh(x)
/** /**
* Computes the hyperbolic cosine of the value [x]. * Computes the hyperbolic cosine of the value [x].
@@ -142,7 +136,7 @@ public inline fun sinh(x: Double): Double = nativeMath.sinh(x)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun cosh(x: Double): Double = nativeMath.cosh(x) public actual inline fun cosh(x: Double): Double = nativeMath.cosh(x)
/** /**
* Computes the hyperbolic tangent of the value [x]. * Computes the hyperbolic tangent of the value [x].
@@ -154,7 +148,7 @@ public inline fun cosh(x: Double): Double = nativeMath.cosh(x)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun tanh(x: Double): Double = nativeMath.tanh(x) public actual inline fun tanh(x: Double): Double = nativeMath.tanh(x)
// Inverse hyperbolic function implementations derived from boost special math functions, // Inverse hyperbolic function implementations derived from boost special math functions,
@@ -171,7 +165,7 @@ public inline fun tanh(x: Double): Double = nativeMath.tanh(x)
* - `asinh(-Inf)` is `-Inf` * - `asinh(-Inf)` is `-Inf`
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
public fun asinh(x: Double): Double = public actual fun asinh(x: Double): Double =
when { when {
x >= +taylor_n_bound -> x >= +taylor_n_bound ->
if (x > upper_taylor_n_bound) { if (x > upper_taylor_n_bound) {
@@ -209,7 +203,7 @@ public fun asinh(x: Double): Double =
* - `acosh(+Inf)` is `+Inf` * - `acosh(+Inf)` is `+Inf`
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
public fun acosh(x: Double): Double = public actual fun acosh(x: Double): Double =
when { when {
x < 1 -> Double.NaN x < 1 -> Double.NaN
@@ -245,7 +239,7 @@ public fun acosh(x: Double): Double =
* - `tanh(-1.0)` is `-Inf` * - `tanh(-1.0)` is `-Inf`
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
public fun atanh(x: Double): Double { public actual fun atanh(x: Double): Double {
if (nativeMath.abs(x) < taylor_n_bound) { if (nativeMath.abs(x) < taylor_n_bound) {
var result = x var result = x
if (nativeMath.abs(x) > taylor_2_bound) { if (nativeMath.abs(x) > taylor_2_bound) {
@@ -265,7 +259,7 @@ public fun atanh(x: Double): Double {
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun hypot(x: Double, y: Double): Double = nativeMath.hypot(x, y) public actual inline fun hypot(x: Double, y: Double): Double = nativeMath.hypot(x, y)
/** /**
* Computes the positive square root of the value [x]. * Computes the positive square root of the value [x].
@@ -275,7 +269,7 @@ public inline fun hypot(x: Double, y: Double): Double = nativeMath.hypot(x, y)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun sqrt(x: Double): Double = nativeMath.sqrt(x) public actual inline fun sqrt(x: Double): Double = nativeMath.sqrt(x)
/** /**
* Computes Euler's number `e` raised to the power of the value [x]. * Computes Euler's number `e` raised to the power of the value [x].
@@ -287,7 +281,7 @@ public inline fun sqrt(x: Double): Double = nativeMath.sqrt(x)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun exp(x: Double): Double = nativeMath.exp(x) public actual inline fun exp(x: Double): Double = nativeMath.exp(x)
/** /**
* Computes `exp(x) - 1`. * Computes `exp(x) - 1`.
@@ -303,7 +297,7 @@ public inline fun exp(x: Double): Double = nativeMath.exp(x)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun expm1(x: Double): Double = nativeMath.expm1(x) public actual inline fun expm1(x: Double): Double = nativeMath.expm1(x)
/** /**
* Computes the logarithm of the value [x] to the given [base]. * Computes the logarithm of the value [x] to the given [base].
@@ -318,7 +312,7 @@ public inline fun expm1(x: Double): Double = nativeMath.expm1(x)
* See also logarithm functions for common fixed bases: [ln], [log10] and [log2]. * See also logarithm functions for common fixed bases: [ln], [log10] and [log2].
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
public fun log(x: Double, base: Double): Double { public actual fun log(x: Double, base: Double): Double {
if (base <= 0.0 || base == 1.0) return Double.NaN if (base <= 0.0 || base == 1.0) return Double.NaN
return nativeMath.log(x) / nativeMath.log(base) return nativeMath.log(x) / nativeMath.log(base)
} }
@@ -334,7 +328,7 @@ public fun log(x: Double, base: Double): Double {
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun ln(x: Double): Double = nativeMath.log(x) public actual inline fun ln(x: Double): Double = nativeMath.log(x)
/** /**
* Computes the common logarithm (base 10) of the value [x]. * Computes the common logarithm (base 10) of the value [x].
@@ -343,7 +337,7 @@ public inline fun ln(x: Double): Double = nativeMath.log(x)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun log10(x: Double): Double = nativeMath.log10(x) public actual inline fun log10(x: Double): Double = nativeMath.log10(x)
/** /**
* Computes the binary logarithm (base 2) of the value [x]. * Computes the binary logarithm (base 2) of the value [x].
@@ -351,7 +345,7 @@ public inline fun log10(x: Double): Double = nativeMath.log10(x)
* @see [ln] function for special cases. * @see [ln] function for special cases.
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
public fun log2(x: Double): Double = nativeMath.log(x) / LN2 public actual fun log2(x: Double): Double = nativeMath.log(x) / LN2
/** /**
* Computes `ln(x + 1)`. * Computes `ln(x + 1)`.
@@ -369,7 +363,7 @@ public fun log2(x: Double): Double = nativeMath.log(x) / LN2
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun ln1p(x: Double): Double = nativeMath.log1p(x) public actual inline fun ln1p(x: Double): Double = nativeMath.log1p(x)
/** /**
* Rounds the given value [x] to an integer towards positive infinity. * Rounds the given value [x] to an integer towards positive infinity.
@@ -381,7 +375,7 @@ public inline fun ln1p(x: Double): Double = nativeMath.log1p(x)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun ceil(x: Double): Double = nativeMath.ceil(x) public actual inline fun ceil(x: Double): Double = nativeMath.ceil(x)
/** /**
* Rounds the given value [x] to an integer towards negative infinity. * Rounds the given value [x] to an integer towards negative infinity.
@@ -393,7 +387,7 @@ public inline fun ceil(x: Double): Double = nativeMath.ceil(x)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun floor(x: Double): Double = nativeMath.floor(x) public actual inline fun floor(x: Double): Double = nativeMath.floor(x)
/** /**
* Rounds the given value [x] to an integer towards zero. * Rounds the given value [x] to an integer towards zero.
@@ -404,7 +398,7 @@ public inline fun floor(x: Double): Double = nativeMath.floor(x)
* - `truncate(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer. * - `truncate(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
public fun truncate(x: Double): Double = when { public actual fun truncate(x: Double): Double = when {
x.isNaN() || x.isInfinite() -> x x.isNaN() || x.isInfinite() -> x
x > 0 -> floor(x) x > 0 -> floor(x)
else -> ceil(x) else -> ceil(x)
@@ -418,7 +412,7 @@ public fun truncate(x: Double): Double = when {
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun round(x: Double): Double = nativeMath.rint(x) public actual inline fun round(x: Double): Double = nativeMath.rint(x)
/** /**
@@ -431,7 +425,7 @@ public inline fun round(x: Double): Double = nativeMath.rint(x)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun abs(x: Double): Double = nativeMath.abs(x) public actual inline fun abs(x: Double): Double = nativeMath.abs(x)
/** /**
* Returns the sign of the given value [x]: * Returns the sign of the given value [x]:
@@ -444,7 +438,7 @@ public inline fun abs(x: Double): Double = nativeMath.abs(x)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun sign(x: Double): Double = nativeMath.signum(x) public actual inline fun sign(x: Double): Double = nativeMath.signum(x)
@@ -455,7 +449,7 @@ public inline fun sign(x: Double): Double = nativeMath.signum(x)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun min(a: Double, b: Double): Double = nativeMath.min(a, b) public actual inline fun min(a: Double, b: Double): Double = nativeMath.min(a, b)
/** /**
* Returns the greater of two values. * Returns the greater of two values.
* *
@@ -463,7 +457,7 @@ public inline fun min(a: Double, b: Double): Double = nativeMath.min(a, b)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun max(a: Double, b: Double): Double = nativeMath.max(a, b) public actual inline fun max(a: Double, b: Double): Double = nativeMath.max(a, b)
// extensions // extensions
@@ -481,7 +475,7 @@ public inline fun max(a: Double, b: Double): Double = nativeMath.max(a, b)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun Double.pow(x: Double): Double = nativeMath.pow(this, x) public actual inline fun Double.pow(x: Double): Double = nativeMath.pow(this, x)
/** /**
* Raises this value to the integer power [n]. * Raises this value to the integer power [n].
@@ -490,7 +484,7 @@ public inline fun Double.pow(x: Double): Double = nativeMath.pow(this, x)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun Double.pow(n: Int): Double = nativeMath.pow(this, n.toDouble()) public actual inline fun Double.pow(n: Int): Double = nativeMath.pow(this, n.toDouble())
/** /**
* Computes the remainder of division of this value by the [divisor] value according to the IEEE 754 standard. * Computes the remainder of division of this value by the [divisor] value according to the IEEE 754 standard.
@@ -518,7 +512,7 @@ public inline fun Double.IEEErem(divisor: Double): Double = nativeMath.IEEEremai
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline val Double.absoluteValue: Double get() = nativeMath.abs(this) public actual inline val Double.absoluteValue: Double get() = nativeMath.abs(this)
/** /**
* Returns the sign of this value: * Returns the sign of this value:
@@ -531,7 +525,7 @@ public inline val Double.absoluteValue: Double get() = nativeMath.abs(this)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline val Double.sign: Double get() = nativeMath.signum(this) public actual inline val Double.sign: Double get() = nativeMath.signum(this)
/** /**
* Returns this value with the sign bit same as of the [sign] value. * Returns this value with the sign bit same as of the [sign] value.
@@ -540,13 +534,13 @@ public inline val Double.sign: Double get() = nativeMath.signum(this)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun Double.withSign(sign: Double): Double = nativeMath.copySign(this, sign) public actual inline fun Double.withSign(sign: Double): Double = nativeMath.copySign(this, sign)
/** /**
* Returns this value with the sign bit same as of the [sign] value. * Returns this value with the sign bit same as of the [sign] value.
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun Double.withSign(sign: Int): Double = nativeMath.copySign(this, sign.toDouble()) public actual inline fun Double.withSign(sign: Int): Double = nativeMath.copySign(this, sign.toDouble())
/** /**
* Returns the ulp (unit in the last place) of this value. * Returns the ulp (unit in the last place) of this value.
@@ -560,20 +554,20 @@ public inline fun Double.withSign(sign: Int): Double = nativeMath.copySign(this,
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline val Double.ulp: Double get() = nativeMath.ulp(this) public actual inline val Double.ulp: Double get() = nativeMath.ulp(this)
/** /**
* Returns the [Double] value nearest to this value in direction of positive infinity. * Returns the [Double] value nearest to this value in direction of positive infinity.
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun Double.nextUp(): Double = nativeMath.nextUp(this) public actual inline fun Double.nextUp(): Double = nativeMath.nextUp(this)
/** /**
* Returns the [Double] value nearest to this value in direction of negative infinity. * Returns the [Double] value nearest to this value in direction of negative infinity.
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun Double.nextDown(): Double = nativeMath.nextAfter(this, Double.NEGATIVE_INFINITY) public actual inline fun Double.nextDown(): Double = nativeMath.nextAfter(this, Double.NEGATIVE_INFINITY)
/** /**
* Returns the [Double] value nearest to this value in direction from this value towards the value [to]. * Returns the [Double] value nearest to this value in direction from this value towards the value [to].
@@ -585,7 +579,7 @@ public inline fun Double.nextDown(): Double = nativeMath.nextAfter(this, Double.
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun Double.nextTowards(to: Double): Double = nativeMath.nextAfter(this, to) public actual inline fun Double.nextTowards(to: Double): Double = nativeMath.nextAfter(this, to)
/** /**
* Rounds this [Double] value to the nearest integer and converts the result to [Int]. * Rounds this [Double] value to the nearest integer and converts the result to [Int].
@@ -598,7 +592,7 @@ public inline fun Double.nextTowards(to: Double): Double = nativeMath.nextAfter(
* @throws IllegalArgumentException when this value is `NaN` * @throws IllegalArgumentException when this value is `NaN`
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
public fun Double.roundToInt(): Int = when { public actual fun Double.roundToInt(): Int = when {
isNaN() -> throw IllegalArgumentException("Cannot round NaN value.") isNaN() -> throw IllegalArgumentException("Cannot round NaN value.")
this > Int.MAX_VALUE -> Int.MAX_VALUE this > Int.MAX_VALUE -> Int.MAX_VALUE
this < Int.MIN_VALUE -> Int.MIN_VALUE this < Int.MIN_VALUE -> Int.MIN_VALUE
@@ -616,7 +610,7 @@ public fun Double.roundToInt(): Int = when {
* @throws IllegalArgumentException when this value is `NaN` * @throws IllegalArgumentException when this value is `NaN`
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
public fun Double.roundToLong(): Long = if (isNaN()) throw IllegalArgumentException("Cannot round NaN value.") else nativeMath.round(this) public actual fun Double.roundToLong(): Long = if (isNaN()) throw IllegalArgumentException("Cannot round NaN value.") else nativeMath.round(this)
@@ -629,7 +623,7 @@ public fun Double.roundToLong(): Long = if (isNaN()) throw IllegalArgumentExcept
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun sin(x: Float): Float = nativeMath.sin(x.toDouble()).toFloat() public actual inline fun sin(x: Float): Float = nativeMath.sin(x.toDouble()).toFloat()
/** Computes the cosine of the angle [x] given in radians. /** Computes the cosine of the angle [x] given in radians.
* *
@@ -638,7 +632,7 @@ public inline fun sin(x: Float): Float = nativeMath.sin(x.toDouble()).toFloat()
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun cos(x: Float): Float = nativeMath.cos(x.toDouble()).toFloat() public actual inline fun cos(x: Float): Float = nativeMath.cos(x.toDouble()).toFloat()
/** Computes the tangent of the angle [x] given in radians. /** Computes the tangent of the angle [x] given in radians.
* *
@@ -647,7 +641,7 @@ public inline fun cos(x: Float): Float = nativeMath.cos(x.toDouble()).toFloat()
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun tan(x: Float): Float = nativeMath.tan(x.toDouble()).toFloat() public actual inline fun tan(x: Float): Float = nativeMath.tan(x.toDouble()).toFloat()
/** /**
* Computes the arc sine of the value [x]; * Computes the arc sine of the value [x];
@@ -658,7 +652,7 @@ public inline fun tan(x: Float): Float = nativeMath.tan(x.toDouble()).toFloat()
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun asin(x: Float): Float = nativeMath.asin(x.toDouble()).toFloat() public actual inline fun asin(x: Float): Float = nativeMath.asin(x.toDouble()).toFloat()
/** /**
* Computes the arc cosine of the value [x]; * Computes the arc cosine of the value [x];
@@ -669,7 +663,7 @@ public inline fun asin(x: Float): Float = nativeMath.asin(x.toDouble()).toFloat(
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun acos(x: Float): Float = nativeMath.acos(x.toDouble()).toFloat() public actual inline fun acos(x: Float): Float = nativeMath.acos(x.toDouble()).toFloat()
/** /**
* Computes the arc tangent of the value [x]; * Computes the arc tangent of the value [x];
@@ -680,7 +674,7 @@ public inline fun acos(x: Float): Float = nativeMath.acos(x.toDouble()).toFloat(
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun atan(x: Float): Float = nativeMath.atan(x.toDouble()).toFloat() public actual inline fun atan(x: Float): Float = nativeMath.atan(x.toDouble()).toFloat()
/** /**
* Returns the angle `theta` of the polar coordinates `(r, theta)` that correspond * Returns the angle `theta` of the polar coordinates `(r, theta)` that correspond
@@ -700,7 +694,7 @@ public inline fun atan(x: Float): Float = nativeMath.atan(x.toDouble()).toFloat(
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun atan2(y: Float, x: Float): Float = nativeMath.atan2(y.toDouble(), x.toDouble()).toFloat() public actual inline fun atan2(y: Float, x: Float): Float = nativeMath.atan2(y.toDouble(), x.toDouble()).toFloat()
/** /**
* Computes the hyperbolic sine of the value [x]. * Computes the hyperbolic sine of the value [x].
@@ -712,7 +706,7 @@ public inline fun atan2(y: Float, x: Float): Float = nativeMath.atan2(y.toDouble
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun sinh(x: Float): Float = nativeMath.sinh(x.toDouble()).toFloat() public actual inline fun sinh(x: Float): Float = nativeMath.sinh(x.toDouble()).toFloat()
/** /**
* Computes the hyperbolic cosine of the value [x]. * Computes the hyperbolic cosine of the value [x].
@@ -723,7 +717,7 @@ public inline fun sinh(x: Float): Float = nativeMath.sinh(x.toDouble()).toFloat(
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun cosh(x: Float): Float = nativeMath.cosh(x.toDouble()).toFloat() public actual inline fun cosh(x: Float): Float = nativeMath.cosh(x.toDouble()).toFloat()
/** /**
* Computes the hyperbolic tangent of the value [x]. * Computes the hyperbolic tangent of the value [x].
@@ -735,7 +729,7 @@ public inline fun cosh(x: Float): Float = nativeMath.cosh(x.toDouble()).toFloat(
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun tanh(x: Float): Float = nativeMath.tanh(x.toDouble()).toFloat() public actual inline fun tanh(x: Float): Float = nativeMath.tanh(x.toDouble()).toFloat()
/** /**
* Computes the inverse hyperbolic sine of the value [x]. * Computes the inverse hyperbolic sine of the value [x].
@@ -749,7 +743,7 @@ public inline fun tanh(x: Float): Float = nativeMath.tanh(x.toDouble()).toFloat(
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun asinh(x: Float): Float = asinh(x.toDouble()).toFloat() public actual inline fun asinh(x: Float): Float = asinh(x.toDouble()).toFloat()
/** /**
* Computes the inverse hyperbolic cosine of the value [x]. * Computes the inverse hyperbolic cosine of the value [x].
@@ -763,7 +757,7 @@ public inline fun asinh(x: Float): Float = asinh(x.toDouble()).toFloat()
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun acosh(x: Float): Float = acosh(x.toDouble()).toFloat() public actual inline fun acosh(x: Float): Float = acosh(x.toDouble()).toFloat()
/** /**
* Computes the inverse hyperbolic tangent of the value [x]. * Computes the inverse hyperbolic tangent of the value [x].
@@ -778,7 +772,7 @@ public inline fun acosh(x: Float): Float = acosh(x.toDouble()).toFloat()
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun atanh(x: Float): Float = atanh(x.toDouble()).toFloat() public actual inline fun atanh(x: Float): Float = atanh(x.toDouble()).toFloat()
/** /**
* Computes `sqrt(x^2 + y^2)` without intermediate overflow or underflow. * Computes `sqrt(x^2 + y^2)` without intermediate overflow or underflow.
@@ -789,7 +783,7 @@ public inline fun atanh(x: Float): Float = atanh(x.toDouble()).toFloat()
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun hypot(x: Float, y: Float): Float = nativeMath.hypot(x.toDouble(), y.toDouble()).toFloat() public actual inline fun hypot(x: Float, y: Float): Float = nativeMath.hypot(x.toDouble(), y.toDouble()).toFloat()
/** /**
* Computes the positive square root of the value [x]. * Computes the positive square root of the value [x].
@@ -799,7 +793,7 @@ public inline fun hypot(x: Float, y: Float): Float = nativeMath.hypot(x.toDouble
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun sqrt(x: Float): Float = nativeMath.sqrt(x.toDouble()).toFloat() public actual inline fun sqrt(x: Float): Float = nativeMath.sqrt(x.toDouble()).toFloat()
/** /**
* Computes Euler's number `e` raised to the power of the value [x]. * Computes Euler's number `e` raised to the power of the value [x].
@@ -811,7 +805,7 @@ public inline fun sqrt(x: Float): Float = nativeMath.sqrt(x.toDouble()).toFloat(
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun exp(x: Float): Float = nativeMath.exp(x.toDouble()).toFloat() public actual inline fun exp(x: Float): Float = nativeMath.exp(x.toDouble()).toFloat()
/** /**
* Computes `exp(x) - 1`. * Computes `exp(x) - 1`.
@@ -827,7 +821,7 @@ public inline fun exp(x: Float): Float = nativeMath.exp(x.toDouble()).toFloat()
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun expm1(x: Float): Float = nativeMath.expm1(x.toDouble()).toFloat() public actual inline fun expm1(x: Float): Float = nativeMath.expm1(x.toDouble()).toFloat()
/** /**
* Computes the logarithm of the value [x] to the given [base]. * Computes the logarithm of the value [x] to the given [base].
@@ -842,7 +836,7 @@ public inline fun expm1(x: Float): Float = nativeMath.expm1(x.toDouble()).toFloa
* See also logarithm functions for common fixed bases: [ln], [log10] and [log2]. * See also logarithm functions for common fixed bases: [ln], [log10] and [log2].
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
public fun log(x: Float, base: Float): Float { public actual fun log(x: Float, base: Float): Float {
if (base <= 0.0F || base == 1.0F) return Float.NaN if (base <= 0.0F || base == 1.0F) return Float.NaN
return (nativeMath.log(x.toDouble()) / nativeMath.log(base.toDouble())).toFloat() return (nativeMath.log(x.toDouble()) / nativeMath.log(base.toDouble())).toFloat()
} }
@@ -858,7 +852,7 @@ public fun log(x: Float, base: Float): Float {
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun ln(x: Float): Float = nativeMath.log(x.toDouble()).toFloat() public actual inline fun ln(x: Float): Float = nativeMath.log(x.toDouble()).toFloat()
/** /**
* Computes the common logarithm (base 10) of the value [x]. * Computes the common logarithm (base 10) of the value [x].
@@ -867,7 +861,7 @@ public inline fun ln(x: Float): Float = nativeMath.log(x.toDouble()).toFloat()
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun log10(x: Float): Float = nativeMath.log10(x.toDouble()).toFloat() public actual inline fun log10(x: Float): Float = nativeMath.log10(x.toDouble()).toFloat()
/** /**
* Computes the binary logarithm (base 2) of the value [x]. * Computes the binary logarithm (base 2) of the value [x].
@@ -875,7 +869,7 @@ public inline fun log10(x: Float): Float = nativeMath.log10(x.toDouble()).toFloa
* @see [ln] function for special cases. * @see [ln] function for special cases.
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
public fun log2(x: Float): Float = (nativeMath.log(x.toDouble()) / LN2).toFloat() public actual fun log2(x: Float): Float = (nativeMath.log(x.toDouble()) / LN2).toFloat()
/** /**
* Computes `ln(a + 1)`. * Computes `ln(a + 1)`.
@@ -893,7 +887,7 @@ public fun log2(x: Float): Float = (nativeMath.log(x.toDouble()) / LN2).toFloat(
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun ln1p(x: Float): Float = nativeMath.log1p(x.toDouble()).toFloat() public actual inline fun ln1p(x: Float): Float = nativeMath.log1p(x.toDouble()).toFloat()
/** /**
* Rounds the given value [x] to an integer towards positive infinity. * Rounds the given value [x] to an integer towards positive infinity.
@@ -905,7 +899,7 @@ public inline fun ln1p(x: Float): Float = nativeMath.log1p(x.toDouble()).toFloat
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun ceil(x: Float): Float = nativeMath.ceil(x.toDouble()).toFloat() public actual inline fun ceil(x: Float): Float = nativeMath.ceil(x.toDouble()).toFloat()
/** /**
* Rounds the given value [x] to an integer towards negative infinity. * Rounds the given value [x] to an integer towards negative infinity.
@@ -917,7 +911,7 @@ public inline fun ceil(x: Float): Float = nativeMath.ceil(x.toDouble()).toFloat(
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun floor(x: Float): Float = nativeMath.floor(x.toDouble()).toFloat() public actual inline fun floor(x: Float): Float = nativeMath.floor(x.toDouble()).toFloat()
/** /**
* Rounds the given value [x] to an integer towards zero. * Rounds the given value [x] to an integer towards zero.
@@ -928,7 +922,7 @@ public inline fun floor(x: Float): Float = nativeMath.floor(x.toDouble()).toFloa
* - `truncate(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer. * - `truncate(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer.
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
public fun truncate(x: Float): Float = when { public actual fun truncate(x: Float): Float = when {
x.isNaN() || x.isInfinite() -> x x.isNaN() || x.isInfinite() -> x
x > 0 -> floor(x) x > 0 -> floor(x)
else -> ceil(x) else -> ceil(x)
@@ -942,7 +936,7 @@ public fun truncate(x: Float): Float = when {
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun round(x: Float): Float = nativeMath.rint(x.toDouble()).toFloat() public actual inline fun round(x: Float): Float = nativeMath.rint(x.toDouble()).toFloat()
/** /**
@@ -955,7 +949,7 @@ public inline fun round(x: Float): Float = nativeMath.rint(x.toDouble()).toFloat
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun abs(x: Float): Float = nativeMath.abs(x) public actual inline fun abs(x: Float): Float = nativeMath.abs(x)
/** /**
* Returns the sign of the given value [x]: * Returns the sign of the given value [x]:
@@ -968,7 +962,7 @@ public inline fun abs(x: Float): Float = nativeMath.abs(x)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun sign(x: Float): Float = nativeMath.signum(x) public actual inline fun sign(x: Float): Float = nativeMath.signum(x)
@@ -979,7 +973,7 @@ public inline fun sign(x: Float): Float = nativeMath.signum(x)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun min(a: Float, b: Float): Float = nativeMath.min(a, b) public actual inline fun min(a: Float, b: Float): Float = nativeMath.min(a, b)
/** /**
* Returns the greater of two values. * Returns the greater of two values.
* *
@@ -987,7 +981,7 @@ public inline fun min(a: Float, b: Float): Float = nativeMath.min(a, b)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun max(a: Float, b: Float): Float = nativeMath.max(a, b) public actual inline fun max(a: Float, b: Float): Float = nativeMath.max(a, b)
// extensions // extensions
@@ -1005,7 +999,7 @@ public inline fun max(a: Float, b: Float): Float = nativeMath.max(a, b)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun Float.pow(x: Float): Float = nativeMath.pow(this.toDouble(), x.toDouble()).toFloat() public actual inline fun Float.pow(x: Float): Float = nativeMath.pow(this.toDouble(), x.toDouble()).toFloat()
/** /**
* Raises this value to the integer power [n]. * Raises this value to the integer power [n].
@@ -1014,7 +1008,7 @@ public inline fun Float.pow(x: Float): Float = nativeMath.pow(this.toDouble(), x
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun Float.pow(n: Int): Float = nativeMath.pow(this.toDouble(), n.toDouble()).toFloat() public actual inline fun Float.pow(n: Int): Float = nativeMath.pow(this.toDouble(), n.toDouble()).toFloat()
/** /**
* Computes the remainder of division of this value by the [divisor] value according to the IEEE 754 standard. * Computes the remainder of division of this value by the [divisor] value according to the IEEE 754 standard.
@@ -1042,7 +1036,7 @@ public inline fun Float.IEEErem(divisor: Float): Float = nativeMath.IEEEremainde
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline val Float.absoluteValue: Float get() = nativeMath.abs(this) public actual inline val Float.absoluteValue: Float get() = nativeMath.abs(this)
/** /**
* Returns the sign of this value: * Returns the sign of this value:
@@ -1055,7 +1049,7 @@ public inline val Float.absoluteValue: Float get() = nativeMath.abs(this)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline val Float.sign: Float get() = nativeMath.signum(this) public actual inline val Float.sign: Float get() = nativeMath.signum(this)
/** /**
* Returns this value with the sign bit same as of the [sign] value. * Returns this value with the sign bit same as of the [sign] value.
@@ -1064,13 +1058,13 @@ public inline val Float.sign: Float get() = nativeMath.signum(this)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun Float.withSign(sign: Float): Float = nativeMath.copySign(this, sign) public actual inline fun Float.withSign(sign: Float): Float = nativeMath.copySign(this, sign)
/** /**
* Returns this value with the sign bit same as of the [sign] value. * Returns this value with the sign bit same as of the [sign] value.
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun Float.withSign(sign: Int): Float = nativeMath.copySign(this, sign.toFloat()) public actual inline fun Float.withSign(sign: Int): Float = nativeMath.copySign(this, sign.toFloat())
/** /**
* Returns the ulp of this value. * Returns the ulp of this value.
@@ -1122,7 +1116,7 @@ public inline fun Float.nextTowards(to: Float): Float = nativeMath.nextAfter(thi
* @throws IllegalArgumentException when this value is `NaN` * @throws IllegalArgumentException when this value is `NaN`
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
public fun Float.roundToInt(): Int = if (isNaN()) throw IllegalArgumentException("Cannot round NaN value.") else nativeMath.round(this) public actual fun Float.roundToInt(): Int = if (isNaN()) throw IllegalArgumentException("Cannot round NaN value.") else nativeMath.round(this)
/** /**
* Rounds this [Float] value to the nearest integer and converts the result to [Long]. * Rounds this [Float] value to the nearest integer and converts the result to [Long].
@@ -1135,7 +1129,7 @@ public fun Float.roundToInt(): Int = if (isNaN()) throw IllegalArgumentException
* @throws IllegalArgumentException when this value is `NaN` * @throws IllegalArgumentException when this value is `NaN`
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
public fun Float.roundToLong(): Long = toDouble().roundToLong() public actual fun Float.roundToLong(): Long = toDouble().roundToLong()
@@ -1151,21 +1145,21 @@ public fun Float.roundToLong(): Long = toDouble().roundToLong()
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun abs(n: Int): Int = nativeMath.abs(n) public actual inline fun abs(n: Int): Int = nativeMath.abs(n)
/** /**
* Returns the smaller of two values. * Returns the smaller of two values.
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun min(a: Int, b: Int): Int = nativeMath.min(a, b) public actual inline fun min(a: Int, b: Int): Int = nativeMath.min(a, b)
/** /**
* Returns the greater of two values. * Returns the greater of two values.
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun max(a: Int, b: Int): Int = nativeMath.max(a, b) public actual inline fun max(a: Int, b: Int): Int = nativeMath.max(a, b)
/** /**
* Returns the absolute value of this value. * Returns the absolute value of this value.
@@ -1177,7 +1171,7 @@ public inline fun max(a: Int, b: Int): Int = nativeMath.max(a, b)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline val Int.absoluteValue: Int get() = nativeMath.abs(this) public actual inline val Int.absoluteValue: Int get() = nativeMath.abs(this)
/** /**
* Returns the sign of this value: * Returns the sign of this value:
@@ -1186,7 +1180,7 @@ public inline val Int.absoluteValue: Int get() = nativeMath.abs(this)
* - `1` if the value is positive * - `1` if the value is positive
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
public val Int.sign: Int get() = when { public actual val Int.sign: Int get() = when {
this < 0 -> -1 this < 0 -> -1
this > 0 -> 1 this > 0 -> 1
else -> 0 else -> 0
@@ -1204,21 +1198,21 @@ public val Int.sign: Int get() = when {
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun abs(n: Long): Long = nativeMath.abs(n) public actual inline fun abs(n: Long): Long = nativeMath.abs(n)
/** /**
* Returns the smaller of two values. * Returns the smaller of two values.
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun min(a: Long, b: Long): Long = nativeMath.min(a, b) public actual inline fun min(a: Long, b: Long): Long = nativeMath.min(a, b)
/** /**
* Returns the greater of two values. * Returns the greater of two values.
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline fun max(a: Long, b: Long): Long = nativeMath.max(a, b) public actual inline fun max(a: Long, b: Long): Long = nativeMath.max(a, b)
/** /**
* Returns the absolute value of this value. * Returns the absolute value of this value.
@@ -1230,7 +1224,7 @@ public inline fun max(a: Long, b: Long): Long = nativeMath.max(a, b)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@InlineOnly @InlineOnly
public inline val Long.absoluteValue: Long get() = nativeMath.abs(this) public actual inline val Long.absoluteValue: Long get() = nativeMath.abs(this)
/** /**
* Returns the sign of this value: * Returns the sign of this value:
@@ -1239,7 +1233,7 @@ public inline val Long.absoluteValue: Long get() = nativeMath.abs(this)
* - `1` if the value is positive * - `1` if the value is positive
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
public val Long.sign: Int get() = when { public actual val Long.sign: Int get() = when {
this < 0 -> -1 this < 0 -> -1
this > 0 -> 1 this > 0 -> 1
else -> 0 else -> 0
@@ -8,38 +8,38 @@ package kotlin
* Not-a-Number (NaN) value, `false` otherwise. * Not-a-Number (NaN) value, `false` otherwise.
*/ */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun Double.isNaN(): Boolean = java.lang.Double.isNaN(this) public actual inline fun Double.isNaN(): Boolean = java.lang.Double.isNaN(this)
/** /**
* Returns `true` if the specified number is a * Returns `true` if the specified number is a
* Not-a-Number (NaN) value, `false` otherwise. * Not-a-Number (NaN) value, `false` otherwise.
*/ */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun Float.isNaN(): Boolean = java.lang.Float.isNaN(this) public actual inline fun Float.isNaN(): Boolean = java.lang.Float.isNaN(this)
/** /**
* Returns `true` if this value is infinitely large in magnitude. * Returns `true` if this value is infinitely large in magnitude.
*/ */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun Double.isInfinite(): Boolean = java.lang.Double.isInfinite(this) public actual inline fun Double.isInfinite(): Boolean = java.lang.Double.isInfinite(this)
/** /**
* Returns `true` if this value is infinitely large in magnitude. * Returns `true` if this value is infinitely large in magnitude.
*/ */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun Float.isInfinite(): Boolean = java.lang.Float.isInfinite(this) public actual inline fun Float.isInfinite(): Boolean = java.lang.Float.isInfinite(this)
/** /**
* Returns `true` if the argument is a finite floating-point value; returns `false` otherwise (for `NaN` and infinity arguments). * Returns `true` if the argument is a finite floating-point value; returns `false` otherwise (for `NaN` and infinity arguments).
*/ */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun Double.isFinite(): Boolean = !isInfinite() && !isNaN() public actual inline fun Double.isFinite(): Boolean = !isInfinite() && !isNaN()
/** /**
* Returns `true` if the argument is a finite floating-point value; returns `false` otherwise (for `NaN` and infinity arguments). * Returns `true` if the argument is a finite floating-point value; returns `false` otherwise (for `NaN` and infinity arguments).
*/ */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun Float.isFinite(): Boolean = !isInfinite() && !isNaN() public actual inline fun Float.isFinite(): Boolean = !isInfinite() && !isNaN()
/** /**
* Returns a bit representation of the specified floating-point value as [Long] * Returns a bit representation of the specified floating-point value as [Long]
@@ -47,7 +47,7 @@ public inline fun Float.isFinite(): Boolean = !isInfinite() && !isNaN()
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun Double.toBits(): Long = java.lang.Double.doubleToLongBits(this) public actual inline fun Double.toBits(): Long = java.lang.Double.doubleToLongBits(this)
/** /**
* Returns a bit representation of the specified floating-point value as [Long] * Returns a bit representation of the specified floating-point value as [Long]
@@ -56,14 +56,14 @@ public inline fun Double.toBits(): Long = java.lang.Double.doubleToLongBits(this
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun Double.toRawBits(): Long = java.lang.Double.doubleToRawLongBits(this) public actual inline fun Double.toRawBits(): Long = java.lang.Double.doubleToRawLongBits(this)
/** /**
* Returns the [Double] value corresponding to a given bit representation. * Returns the [Double] value corresponding to a given bit representation.
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun Double.Companion.fromBits(bits: Long): Double = java.lang.Double.longBitsToDouble(bits) public actual inline fun Double.Companion.fromBits(bits: Long): Double = java.lang.Double.longBitsToDouble(bits)
/** /**
* Returns a bit representation of the specified floating-point value as [Int] * Returns a bit representation of the specified floating-point value as [Int]
@@ -71,7 +71,7 @@ public inline fun Double.Companion.fromBits(bits: Long): Double = java.lang.Doub
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun Float.toBits(): Int = java.lang.Float.floatToIntBits(this) public actual inline fun Float.toBits(): Int = java.lang.Float.floatToIntBits(this)
/** /**
* Returns a bit representation of the specified floating-point value as [Int] * Returns a bit representation of the specified floating-point value as [Int]
@@ -80,11 +80,11 @@ public inline fun Float.toBits(): Int = java.lang.Float.floatToIntBits(this)
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun Float.toRawBits(): Int = java.lang.Float.floatToRawIntBits(this) public actual inline fun Float.toRawBits(): Int = java.lang.Float.floatToRawIntBits(this)
/** /**
* Returns the [Float] value corresponding to a given bit representation. * Returns the [Float] value corresponding to a given bit representation.
*/ */
@SinceKotlin("1.2") @SinceKotlin("1.2")
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun Float.Companion.fromBits(bits: Int): Float = java.lang.Float.intBitsToFloat(bits) public actual inline fun Float.Companion.fromBits(bits: Int): Float = java.lang.Float.intBitsToFloat(bits)
@@ -9,7 +9,7 @@ import kotlin.jvm.internal.unsafe.*
* Executes the given function [block] while holding the monitor of the given object [lock]. * Executes the given function [block] while holding the monitor of the given object [lock].
*/ */
@kotlin.internal.InlineOnly @kotlin.internal.InlineOnly
public inline fun <R> synchronized(lock: Any, block: () -> R): R { public actual inline fun <R> synchronized(lock: Any, block: () -> R): R {
@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE", "INVISIBLE_MEMBER") @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE", "INVISIBLE_MEMBER")
monitorEnter(lock) monitorEnter(lock)
try { try {
@@ -1,13 +0,0 @@
@file:kotlin.jvm.JvmVersion
package kotlin.collections
@SinceKotlin("1.1") public typealias RandomAccess = java.util.RandomAccess
@SinceKotlin("1.1") public typealias ArrayList<E> = java.util.ArrayList<E>
@SinceKotlin("1.1") public typealias LinkedHashMap<K, V> = java.util.LinkedHashMap<K, V>
@SinceKotlin("1.1") public typealias HashMap<K, V> = java.util.HashMap<K, V>
@SinceKotlin("1.1") public typealias LinkedHashSet<E> = java.util.LinkedHashSet<E>
@SinceKotlin("1.1") public typealias HashSet<E> = java.util.HashSet<E>
+1 -1
View File
@@ -53,7 +53,7 @@ the Kotlin IntelliJ IDEA plugin:
- License: Apache 2 (license/third_party/gwt_license.txt) - License: Apache 2 (license/third_party/gwt_license.txt)
- Origin: Derived from GWT, (C) 2007-08 Google Inc. - Origin: Derived from GWT, (C) 2007-08 Google Inc.
- Path: libraries/stdlib/src/kotlin/util/MathJVM.kt - Path: libraries/stdlib/jvm/src/kotlin/util/MathJVM.kt
- License: Boost Software License 1.0 (license/third_party/boost_LICENSE.txt) - License: Boost Software License 1.0 (license/third_party/boost_LICENSE.txt)
- Origin: Derived from boost special math functions, Copyright Eric Ford & Hubert Holin 2001. - Origin: Derived from boost special math functions, Copyright Eric Ford & Hubert Holin 2001.