Reformat stdlib: jvm part
#KT-5558
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
@file:Suppress("UNCHECKED_CAST", "NOTHING_TO_INLINE", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
@file:Suppress("UNCHECKED_CAST", "NOTHING_TO_INLINE", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||||
@file:JvmName("CollectionsJDK8Kt")
|
@file:JvmName("CollectionsJDK8Kt")
|
||||||
@file:kotlin.jvm.JvmPackageName("kotlin.collections.jdk8")
|
@file:kotlin.jvm.JvmPackageName("kotlin.collections.jdk8")
|
||||||
|
|
||||||
package kotlin.collections
|
package kotlin.collections
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,8 +26,8 @@ package kotlin.collections
|
|||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.getOrDefault(key: K, defaultValue: V): V
|
public inline fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.getOrDefault(key: K, defaultValue: V): V =
|
||||||
= (this as Map<K, V>).getOrDefault(key, defaultValue)
|
(this as Map<K, V>).getOrDefault(key, defaultValue)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,5 +36,5 @@ public inline fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.getOrDefa
|
|||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun <@kotlin.internal.OnlyInputTypes K, @kotlin.internal.OnlyInputTypes V> MutableMap<out K, out V>.remove(key: K, value: V): Boolean
|
public inline fun <@kotlin.internal.OnlyInputTypes K, @kotlin.internal.OnlyInputTypes V> MutableMap<out K, out V>.remove(key: K, value: V): Boolean =
|
||||||
= (this as MutableMap<K, V>).remove(key, value)
|
(this as MutableMap<K, V>).remove(key, value)
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ public fun DoubleStream.asSequence(): Sequence<Double> = Sequence { iterator() }
|
|||||||
* Creates a sequential [Stream] instance that produces elements from the original sequence.
|
* Creates a sequential [Stream] instance that produces elements from the original sequence.
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public fun <T> Sequence<T>.asStream(): Stream<T> = StreamSupport.stream({ Spliterators.spliteratorUnknownSize(iterator(), Spliterator.ORDERED) }, Spliterator.ORDERED, false)
|
public fun <T> Sequence<T>.asStream(): Stream<T> =
|
||||||
|
StreamSupport.stream({ Spliterators.spliteratorUnknownSize(iterator(), Spliterator.ORDERED) }, Spliterator.ORDERED, false)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a [List] containing all elements produced by this stream.
|
* Returns a [List] containing all elements produced by this stream.
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ package kotlin.text
|
|||||||
*/
|
*/
|
||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
public operator fun MatchGroupCollection.get(name: String): MatchGroup? {
|
public operator fun MatchGroupCollection.get(name: String): MatchGroup? {
|
||||||
val namedGroups = this as? MatchNamedGroupCollection ?:
|
val namedGroups = this as? MatchNamedGroupCollection
|
||||||
throw UnsupportedOperationException("Retrieving groups by name is not supported on this platform.")
|
?: throw UnsupportedOperationException("Retrieving groups by name is not supported on this platform.")
|
||||||
|
|
||||||
return namedGroups[name]
|
return namedGroups[name]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@file:JvmName("ThreadsKt")
|
@file:JvmName("ThreadsKt")
|
||||||
|
|
||||||
package kotlin.concurrent
|
package kotlin.concurrent
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -16,7 +17,14 @@ package kotlin.concurrent
|
|||||||
* @param name the name of the thread.
|
* @param name the name of the thread.
|
||||||
* @param priority the priority of the thread.
|
* @param priority the priority of the thread.
|
||||||
*/
|
*/
|
||||||
public fun thread(start: Boolean = true, isDaemon: Boolean = false, contextClassLoader: ClassLoader? = null, name: String? = null, priority: Int = -1, block: () -> Unit): Thread {
|
public fun thread(
|
||||||
|
start: Boolean = true,
|
||||||
|
isDaemon: Boolean = false,
|
||||||
|
contextClassLoader: ClassLoader? = null,
|
||||||
|
name: String? = null,
|
||||||
|
priority: Int = -1,
|
||||||
|
block: () -> Unit
|
||||||
|
): Thread {
|
||||||
val thread = object : Thread() {
|
val thread = object : Thread() {
|
||||||
public override fun run() {
|
public override fun run() {
|
||||||
block()
|
block()
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ internal actual constructor(
|
|||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
private val RESULT = AtomicReferenceFieldUpdater.newUpdater<SafeContinuation<*>, Any?>(
|
private val RESULT = AtomicReferenceFieldUpdater.newUpdater<SafeContinuation<*>, Any?>(
|
||||||
SafeContinuation::class.java, Any::class.java as Class<Any?>, "result")
|
SafeContinuation::class.java, Any::class.java as Class<Any?>, "result"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Fail(val exception: Throwable)
|
private class Fail(val exception: Throwable)
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
|
|
||||||
@file:kotlin.jvm.JvmName("IntrinsicsKt")
|
@file:kotlin.jvm.JvmName("IntrinsicsKt")
|
||||||
@file:kotlin.jvm.JvmMultifileClass
|
@file:kotlin.jvm.JvmMultifileClass
|
||||||
|
|
||||||
package kotlin.coroutines.experimental.intrinsics
|
package kotlin.coroutines.experimental.intrinsics
|
||||||
|
|
||||||
import kotlin.coroutines.experimental.*
|
import kotlin.coroutines.experimental.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@file:JvmName("CoroutineIntrinsics")
|
@file:JvmName("CoroutineIntrinsics")
|
||||||
|
|
||||||
package kotlin.coroutines.experimental.jvm.internal
|
package kotlin.coroutines.experimental.jvm.internal
|
||||||
|
|
||||||
import kotlin.coroutines.experimental.Continuation
|
import kotlin.coroutines.experimental.Continuation
|
||||||
|
|||||||
@@ -26,23 +26,19 @@ internal val IMPLEMENTATIONS: PlatformImplementations = run {
|
|||||||
if (version >= 0x10008) {
|
if (version >= 0x10008) {
|
||||||
try {
|
try {
|
||||||
return@run Class.forName("kotlin.internal.jdk8.JDK8PlatformImplementations").newInstance() as PlatformImplementations
|
return@run Class.forName("kotlin.internal.jdk8.JDK8PlatformImplementations").newInstance() as PlatformImplementations
|
||||||
}
|
} catch (e: ClassNotFoundException) { }
|
||||||
catch (e: ClassNotFoundException) { }
|
|
||||||
try {
|
try {
|
||||||
return@run Class.forName("kotlin.internal.JRE8PlatformImplementations").newInstance() as PlatformImplementations
|
return@run Class.forName("kotlin.internal.JRE8PlatformImplementations").newInstance() as PlatformImplementations
|
||||||
}
|
} catch (e: ClassNotFoundException) { }
|
||||||
catch (e: ClassNotFoundException) { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version >= 0x10007) {
|
if (version >= 0x10007) {
|
||||||
try {
|
try {
|
||||||
return@run Class.forName("kotlin.internal.jdk7.JDK7PlatformImplementations").newInstance() as PlatformImplementations
|
return@run Class.forName("kotlin.internal.jdk7.JDK7PlatformImplementations").newInstance() as PlatformImplementations
|
||||||
}
|
} catch (e: ClassNotFoundException) { }
|
||||||
catch (e: ClassNotFoundException) { }
|
|
||||||
try {
|
try {
|
||||||
return@run Class.forName("kotlin.internal.JRE7PlatformImplementations").newInstance() as PlatformImplementations
|
return@run Class.forName("kotlin.internal.JRE7PlatformImplementations").newInstance() as PlatformImplementations
|
||||||
}
|
} catch (e: ClassNotFoundException) { }
|
||||||
catch (e: ClassNotFoundException) { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlatformImplementations()
|
PlatformImplementations()
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@file:JvmName("ConstantsKt")
|
@file:JvmName("ConstantsKt")
|
||||||
|
|
||||||
package kotlin.io
|
package kotlin.io
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ private fun constructMessage(file: File, other: File?, reason: String?): String
|
|||||||
* @property other the second file involved in the operation, if any (for example, the target of a copy or move)
|
* @property other the second file involved in the operation, if any (for example, the target of a copy or move)
|
||||||
* @property reason the description of the error
|
* @property reason the description of the error
|
||||||
*/
|
*/
|
||||||
open public class FileSystemException(public val file: File,
|
open public class FileSystemException(
|
||||||
|
public val file: File,
|
||||||
public val other: File? = null,
|
public val other: File? = null,
|
||||||
public val reason: String? = null
|
public val reason: String? = null
|
||||||
) : IOException(constructMessage(file, other, reason))
|
) : IOException(constructMessage(file, other, reason))
|
||||||
@@ -34,21 +35,27 @@ open public class FileSystemException(public val file: File,
|
|||||||
/**
|
/**
|
||||||
* An exception class which is used when some file to create or copy to already exists.
|
* An exception class which is used when some file to create or copy to already exists.
|
||||||
*/
|
*/
|
||||||
public class FileAlreadyExistsException(file: File,
|
public class FileAlreadyExistsException(
|
||||||
|
file: File,
|
||||||
other: File? = null,
|
other: File? = null,
|
||||||
reason: String? = null) : FileSystemException(file, other, reason)
|
reason: String? = null
|
||||||
|
) : FileSystemException(file, other, reason)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An exception class which is used when we have not enough access for some operation.
|
* An exception class which is used when we have not enough access for some operation.
|
||||||
*/
|
*/
|
||||||
public class AccessDeniedException(file: File,
|
public class AccessDeniedException(
|
||||||
|
file: File,
|
||||||
other: File? = null,
|
other: File? = null,
|
||||||
reason: String? = null) : FileSystemException(file, other, reason)
|
reason: String? = null
|
||||||
|
) : FileSystemException(file, other, reason)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An exception class which is used when file to copy does not exist.
|
* An exception class which is used when file to copy does not exist.
|
||||||
*/
|
*/
|
||||||
public class NoSuchFileException(file: File,
|
public class NoSuchFileException(
|
||||||
|
file: File,
|
||||||
other: File? = null,
|
other: File? = null,
|
||||||
reason: String? = null) : FileSystemException(file, other, reason)
|
reason: String? = null
|
||||||
|
) : FileSystemException(file, other, reason)
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
@file:JvmMultifileClass
|
@file:JvmMultifileClass
|
||||||
@file:JvmName("FilesKt")
|
@file:JvmName("FilesKt")
|
||||||
|
|
||||||
package kotlin.io
|
package kotlin.io
|
||||||
|
|
||||||
import java.io.*
|
import java.io.*
|
||||||
@@ -17,7 +18,8 @@ import kotlin.internal.*
|
|||||||
* Returns a new [FileReader] for reading the content of this file.
|
* Returns a new [FileReader] for reading the content of this file.
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun File.reader(charset: Charset = Charsets.UTF_8): InputStreamReader = inputStream().reader(charset)
|
public inline fun File.reader(charset: Charset = Charsets.UTF_8): InputStreamReader =
|
||||||
|
inputStream().reader(charset)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new [BufferedReader] for reading the content of this file.
|
* Returns a new [BufferedReader] for reading the content of this file.
|
||||||
@@ -25,13 +27,15 @@ public inline fun File.reader(charset: Charset = Charsets.UTF_8): InputStreamRea
|
|||||||
* @param bufferSize necessary size of the buffer.
|
* @param bufferSize necessary size of the buffer.
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun File.bufferedReader(charset: Charset = Charsets.UTF_8, bufferSize: Int = DEFAULT_BUFFER_SIZE): BufferedReader = reader(charset).buffered(bufferSize)
|
public inline fun File.bufferedReader(charset: Charset = Charsets.UTF_8, bufferSize: Int = DEFAULT_BUFFER_SIZE): BufferedReader =
|
||||||
|
reader(charset).buffered(bufferSize)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new [FileWriter] for writing the content of this file.
|
* Returns a new [FileWriter] for writing the content of this file.
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun File.writer(charset: Charset = Charsets.UTF_8): OutputStreamWriter = outputStream().writer(charset)
|
public inline fun File.writer(charset: Charset = Charsets.UTF_8): OutputStreamWriter =
|
||||||
|
outputStream().writer(charset)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new [BufferedWriter] for writing the content of this file.
|
* Returns a new [BufferedWriter] for writing the content of this file.
|
||||||
@@ -39,13 +43,15 @@ public inline fun File.writer(charset: Charset = Charsets.UTF_8): OutputStreamWr
|
|||||||
* @param bufferSize necessary size of the buffer.
|
* @param bufferSize necessary size of the buffer.
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun File.bufferedWriter(charset: Charset = Charsets.UTF_8, bufferSize: Int = DEFAULT_BUFFER_SIZE): BufferedWriter = writer(charset).buffered(bufferSize)
|
public inline fun File.bufferedWriter(charset: Charset = Charsets.UTF_8, bufferSize: Int = DEFAULT_BUFFER_SIZE): BufferedWriter =
|
||||||
|
writer(charset).buffered(bufferSize)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new [PrintWriter] for writing the content of this file.
|
* Returns a new [PrintWriter] for writing the content of this file.
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun File.printWriter(charset: Charset = Charsets.UTF_8): PrintWriter = PrintWriter(bufferedWriter(charset))
|
public inline fun File.printWriter(charset: Charset = Charsets.UTF_8): PrintWriter =
|
||||||
|
PrintWriter(bufferedWriter(charset))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the entire content of this file as a byte array.
|
* Gets the entire content of this file as a byte array.
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@file:JvmName("ByteStreamsKt")
|
@file:JvmName("ByteStreamsKt")
|
||||||
|
|
||||||
package kotlin.io
|
package kotlin.io
|
||||||
|
|
||||||
import java.io.*
|
import java.io.*
|
||||||
@@ -67,8 +68,8 @@ public inline fun ByteArray.inputStream(offset: Int, length: Int) : ByteArrayInp
|
|||||||
* @param bufferSize the buffer size to use.
|
* @param bufferSize the buffer size to use.
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun InputStream.buffered(bufferSize: Int = DEFAULT_BUFFER_SIZE): BufferedInputStream
|
public inline fun InputStream.buffered(bufferSize: Int = DEFAULT_BUFFER_SIZE): BufferedInputStream =
|
||||||
= if (this is BufferedInputStream) this else BufferedInputStream(this, bufferSize)
|
if (this is BufferedInputStream) this else BufferedInputStream(this, bufferSize)
|
||||||
|
|
||||||
/** Creates a reader on this input stream using UTF-8 or the specified [charset]. */
|
/** Creates a reader on this input stream using UTF-8 or the specified [charset]. */
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
@@ -83,8 +84,8 @@ public inline fun InputStream.bufferedReader(charset: Charset = Charsets.UTF_8):
|
|||||||
* @param bufferSize the buffer size to use.
|
* @param bufferSize the buffer size to use.
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun OutputStream.buffered(bufferSize: Int = DEFAULT_BUFFER_SIZE): BufferedOutputStream
|
public inline fun OutputStream.buffered(bufferSize: Int = DEFAULT_BUFFER_SIZE): BufferedOutputStream =
|
||||||
= if (this is BufferedOutputStream) this else BufferedOutputStream(this, bufferSize)
|
if (this is BufferedOutputStream) this else BufferedOutputStream(this, bufferSize)
|
||||||
|
|
||||||
/** Creates a writer on this output stream using UTF-8 or the specified [charset]. */
|
/** Creates a writer on this output stream using UTF-8 or the specified [charset]. */
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@file:JvmName("TextStreamsKt")
|
@file:JvmName("TextStreamsKt")
|
||||||
|
|
||||||
package kotlin.io
|
package kotlin.io
|
||||||
|
|
||||||
import java.io.*
|
import java.io.*
|
||||||
@@ -15,13 +16,13 @@ import kotlin.internal.*
|
|||||||
|
|
||||||
/** Returns a buffered reader wrapping this Reader, or this Reader itself if it is already buffered. */
|
/** Returns a buffered reader wrapping this Reader, or this Reader itself if it is already buffered. */
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun Reader.buffered(bufferSize: Int = DEFAULT_BUFFER_SIZE): BufferedReader
|
public inline fun Reader.buffered(bufferSize: Int = DEFAULT_BUFFER_SIZE): BufferedReader =
|
||||||
= if (this is BufferedReader) this else BufferedReader(this, bufferSize)
|
if (this is BufferedReader) this else BufferedReader(this, bufferSize)
|
||||||
|
|
||||||
/** Returns a buffered reader wrapping this Writer, or this Writer itself if it is already buffered. */
|
/** Returns a buffered reader wrapping this Writer, or this Writer itself if it is already buffered. */
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun Writer.buffered(bufferSize: Int = DEFAULT_BUFFER_SIZE): BufferedWriter
|
public inline fun Writer.buffered(bufferSize: Int = DEFAULT_BUFFER_SIZE): BufferedWriter =
|
||||||
= if (this is BufferedWriter) this else BufferedWriter(this, bufferSize)
|
if (this is BufferedWriter) this else BufferedWriter(this, bufferSize)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates through each line of this reader, calls [action] for each line read
|
* Iterates through each line of this reader, calls [action] for each line read
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
@file:JvmMultifileClass
|
@file:JvmMultifileClass
|
||||||
@file:JvmName("FilesKt")
|
@file:JvmName("FilesKt")
|
||||||
|
|
||||||
package kotlin.io
|
package kotlin.io
|
||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
@file:JvmMultifileClass
|
@file:JvmMultifileClass
|
||||||
@file:JvmName("FilesKt")
|
@file:JvmName("FilesKt")
|
||||||
|
|
||||||
package kotlin.io
|
package kotlin.io
|
||||||
|
|
||||||
import kotlin.*
|
import kotlin.*
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
@file:JvmMultifileClass
|
@file:JvmMultifileClass
|
||||||
@file:JvmName("FilesKt")
|
@file:JvmName("FilesKt")
|
||||||
|
|
||||||
package kotlin.io
|
package kotlin.io
|
||||||
|
|
||||||
import java.io.*
|
import java.io.*
|
||||||
@@ -79,8 +80,8 @@ public val File.nameWithoutExtension: String
|
|||||||
*
|
*
|
||||||
* @throws IllegalArgumentException if this and base paths have different roots.
|
* @throws IllegalArgumentException if this and base paths have different roots.
|
||||||
*/
|
*/
|
||||||
public fun File.toRelativeString(base: File): String
|
public fun File.toRelativeString(base: File): String =
|
||||||
= toRelativeStringOrNull(base) ?: throw IllegalArgumentException("this and base files have different roots: $this and $base.")
|
toRelativeStringOrNull(base) ?: throw IllegalArgumentException("this and base files have different roots: $this and $base.")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the relative path for this file from [base] file.
|
* Calculates the relative path for this file from [base] file.
|
||||||
@@ -100,8 +101,8 @@ public fun File.relativeTo(base: File): File = File(this.toRelativeString(base))
|
|||||||
*
|
*
|
||||||
* @return File with relative path from [base] to this, or `this` if this and base paths have different roots.
|
* @return File with relative path from [base] to this, or `this` if this and base paths have different roots.
|
||||||
*/
|
*/
|
||||||
public fun File.relativeToOrSelf(base: File): File
|
public fun File.relativeToOrSelf(base: File): File =
|
||||||
= toRelativeStringOrNull(base)?.let(::File) ?: this
|
toRelativeStringOrNull(base)?.let(::File) ?: this
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the relative path for this file from [base] file.
|
* Calculates the relative path for this file from [base] file.
|
||||||
@@ -110,8 +111,8 @@ public fun File.relativeToOrSelf(base: File): File
|
|||||||
*
|
*
|
||||||
* @return File with relative path from [base] to this, or `null` if this and base paths have different roots.
|
* @return File with relative path from [base] to this, or `null` if this and base paths have different roots.
|
||||||
*/
|
*/
|
||||||
public fun File.relativeToOrNull(base: File): File?
|
public fun File.relativeToOrNull(base: File): File? =
|
||||||
= toRelativeStringOrNull(base)?.let(::File)
|
toRelativeStringOrNull(base)?.let(::File)
|
||||||
|
|
||||||
|
|
||||||
private fun File.toRelativeStringOrNull(base: File): String? {
|
private fun File.toRelativeStringOrNull(base: File): String? {
|
||||||
@@ -189,9 +190,11 @@ public fun File.copyTo(target: File, overwrite: Boolean = false, bufferSize: Int
|
|||||||
val stillExists = if (!overwrite) true else !target.delete()
|
val stillExists = if (!overwrite) true else !target.delete()
|
||||||
|
|
||||||
if (stillExists) {
|
if (stillExists) {
|
||||||
throw FileAlreadyExistsException(file = this,
|
throw FileAlreadyExistsException(
|
||||||
|
file = this,
|
||||||
other = target,
|
other = target,
|
||||||
reason = "The destination file already exists.")
|
reason = "The destination file already exists."
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,10 +257,10 @@ private class TerminateException(file: File) : FileSystemException(file) {}
|
|||||||
* @param overwrite `true` if it is allowed to overwrite existing destination files and directories.
|
* @param overwrite `true` if it is allowed to overwrite existing destination files and directories.
|
||||||
* @return `false` if the copying was terminated, `true` otherwise.
|
* @return `false` if the copying was terminated, `true` otherwise.
|
||||||
*/
|
*/
|
||||||
public fun File.copyRecursively(target: File,
|
public fun File.copyRecursively(
|
||||||
|
target: File,
|
||||||
overwrite: Boolean = false,
|
overwrite: Boolean = false,
|
||||||
onError: (File, IOException) -> OnErrorAction =
|
onError: (File, IOException) -> OnErrorAction = { _, exception -> throw exception }
|
||||||
{ _, exception -> throw exception }
|
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (!exists()) {
|
if (!exists()) {
|
||||||
return onError(this, NoSuchFileException(file = this, reason = "The source file doesn't exist.")) !=
|
return onError(this, NoSuchFileException(file = this, reason = "The source file doesn't exist.")) !=
|
||||||
@@ -375,11 +378,11 @@ public fun File.endsWith(other: String): Boolean = endsWith(File(other))
|
|||||||
*
|
*
|
||||||
* @return normalized pathname with . and possibly .. removed.
|
* @return normalized pathname with . and possibly .. removed.
|
||||||
*/
|
*/
|
||||||
public fun File.normalize(): File
|
public fun File.normalize(): File =
|
||||||
= with (toComponents()) { root.resolve(segments.normalize().joinToString(File.separator)) }
|
with(toComponents()) { root.resolve(segments.normalize().joinToString(File.separator)) }
|
||||||
|
|
||||||
private fun FilePathComponents.normalize(): FilePathComponents
|
private fun FilePathComponents.normalize(): FilePathComponents =
|
||||||
= FilePathComponents(root, segments.normalize())
|
FilePathComponents(root, segments.normalize())
|
||||||
|
|
||||||
private fun List<File>.normalize(): List<File> {
|
private fun List<File>.normalize(): List<File> {
|
||||||
val list: MutableList<File> = ArrayList(this.size)
|
val list: MutableList<File> = ArrayList(this.size)
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ package kotlin.jvm.internal.unsafe
|
|||||||
|
|
||||||
import kotlin.*
|
import kotlin.*
|
||||||
|
|
||||||
private fun monitorEnter(@Suppress("UNUSED_PARAMETER") monitor: Any): Unit = throw UnsupportedOperationException("This function can only be used privately")
|
private fun monitorEnter(@Suppress("UNUSED_PARAMETER") monitor: Any): Unit =
|
||||||
|
throw UnsupportedOperationException("This function can only be used privately")
|
||||||
|
|
||||||
private fun monitorExit(@Suppress("UNUSED_PARAMETER") monitor: Any): Unit = throw UnsupportedOperationException("This function can only be used privately")
|
private fun monitorExit(@Suppress("UNUSED_PARAMETER") monitor: Any): Unit =
|
||||||
|
throw UnsupportedOperationException("This function can only be used privately")
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
@file:kotlin.jvm.JvmMultifileClass
|
@file:kotlin.jvm.JvmMultifileClass
|
||||||
@file:kotlin.jvm.JvmName("RangesKt")
|
@file:kotlin.jvm.JvmName("RangesKt")
|
||||||
|
|
||||||
package kotlin.ranges
|
package kotlin.ranges
|
||||||
|
|
||||||
import kotlin.*
|
import kotlin.*
|
||||||
@@ -36,6 +37,7 @@ private class ClosedFloatRange (
|
|||||||
override fun hashCode(): Int {
|
override fun hashCode(): Int {
|
||||||
return if (isEmpty()) -1 else 31 * _start.hashCode() + _endInclusive.hashCode()
|
return if (isEmpty()) -1 else 31 * _start.hashCode() + _endInclusive.hashCode()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String = "$_start..$_endInclusive"
|
override fun toString(): String = "$_start..$_endInclusive"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,12 @@ public inline fun String.toCharArray(): CharArray = (this as java.lang.String).t
|
|||||||
* @param endIndex the end offset (exclusive) of the substring to copy.
|
* @param endIndex the end offset (exclusive) of the substring to copy.
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun String.toCharArray(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = length): CharArray {
|
public inline fun String.toCharArray(
|
||||||
|
destination: CharArray,
|
||||||
|
destinationOffset: Int = 0,
|
||||||
|
startIndex: Int = 0,
|
||||||
|
endIndex: Int = length
|
||||||
|
): CharArray {
|
||||||
(this as java.lang.String).getChars(startIndex, endIndex, destination, destinationOffset)
|
(this as java.lang.String).getChars(startIndex, endIndex, destination, destinationOffset)
|
||||||
return destination
|
return destination
|
||||||
}
|
}
|
||||||
@@ -150,7 +155,8 @@ public inline fun String.format(locale: Locale, vararg args : Any?) : String = j
|
|||||||
* using the specified locale.
|
* using the specified locale.
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun String.Companion.format(locale: Locale, format: String, vararg args: Any?): String = java.lang.String.format(locale, format, *args)
|
public inline fun String.Companion.format(locale: Locale, format: String, vararg args: Any?): String =
|
||||||
|
java.lang.String.format(locale, format, *args)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Splits this char sequence around matches of the given regular expression.
|
* Splits this char sequence around matches of the given regular expression.
|
||||||
@@ -158,8 +164,7 @@ public inline fun String.Companion.format(locale: Locale, format: String, vararg
|
|||||||
* @param limit Non-negative value specifying the maximum number of substrings to return.
|
* @param limit Non-negative value specifying the maximum number of substrings to return.
|
||||||
* Zero by default means no limit is set.
|
* Zero by default means no limit is set.
|
||||||
*/
|
*/
|
||||||
public fun CharSequence.split(regex: Pattern, limit: Int = 0): List<String>
|
public fun CharSequence.split(regex: Pattern, 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 regex.split(this, if (limit == 0) -1 else limit).asList()
|
return regex.split(this, if (limit == 0) -1 else limit).asList()
|
||||||
}
|
}
|
||||||
@@ -221,7 +226,8 @@ public fun String.endsWith(suffix: String, ignoreCase: Boolean = false): Boolean
|
|||||||
* @param charset the character set to use.
|
* @param charset the character set to use.
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun String(bytes: ByteArray, offset: Int, length: Int, charset: Charset): String = java.lang.String(bytes, offset, length, charset) as String
|
public inline fun String(bytes: ByteArray, offset: Int, length: Int, charset: Charset): String =
|
||||||
|
java.lang.String(bytes, offset, length, charset) as String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the data from the specified array of bytes to characters using the specified character set
|
* Converts the data from the specified array of bytes to characters using the specified character set
|
||||||
@@ -239,44 +245,51 @@ public inline fun String(bytes: ByteArray, charset: Charset): String = java.lang
|
|||||||
* @param length the number of bytes to be converted.
|
* @param length the number of bytes to be converted.
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun String(bytes: ByteArray, offset: Int, length: Int): String = java.lang.String(bytes, offset, length, Charsets.UTF_8) as String
|
public inline fun String(bytes: ByteArray, offset: Int, length: Int): String =
|
||||||
|
java.lang.String(bytes, offset, length, Charsets.UTF_8) as String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the data from the specified array of bytes to characters using the UTF-8 character set
|
* Converts the data from the specified array of bytes to characters using the UTF-8 character set
|
||||||
* and returns the conversion result as a string.
|
* and returns the conversion result as a string.
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun String(bytes: ByteArray): String = java.lang.String(bytes, Charsets.UTF_8) as String
|
public inline fun String(bytes: ByteArray): String =
|
||||||
|
java.lang.String(bytes, Charsets.UTF_8) as String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the characters in the specified array to a string.
|
* Converts the characters in the specified array to a string.
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun String(chars: CharArray): String = java.lang.String(chars) as String
|
public inline fun String(chars: CharArray): String =
|
||||||
|
java.lang.String(chars) as String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the characters from a portion of the specified array to a string.
|
* Converts the characters from a portion of the specified array to a string.
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun String(chars: CharArray, offset: Int, length: Int): String = java.lang.String(chars, offset, length) as String
|
public inline fun String(chars: CharArray, offset: Int, length: Int): String =
|
||||||
|
java.lang.String(chars, offset, length) as String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the code points from a portion of the specified Unicode code point array to a string.
|
* Converts the code points from a portion of the specified Unicode code point array to a string.
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun String(codePoints: IntArray, offset: Int, length: Int): String = java.lang.String(codePoints, offset, length) as String
|
public inline fun String(codePoints: IntArray, offset: Int, length: Int): String =
|
||||||
|
java.lang.String(codePoints, offset, length) as String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the contents of the specified StringBuffer to a string.
|
* Converts the contents of the specified StringBuffer to a string.
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun String(stringBuffer: java.lang.StringBuffer): String = java.lang.String(stringBuffer) as String
|
public inline fun String(stringBuffer: java.lang.StringBuffer): String =
|
||||||
|
java.lang.String(stringBuffer) as String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the contents of the specified StringBuilder to a string.
|
* Converts the contents of the specified StringBuilder to a string.
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun String(stringBuilder: java.lang.StringBuilder): String = java.lang.String(stringBuilder) as String
|
public inline fun String(stringBuilder: java.lang.StringBuilder): String =
|
||||||
|
java.lang.String(stringBuilder) as String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the character (Unicode code point) at the specified index.
|
* Returns the character (Unicode code point) at the specified index.
|
||||||
@@ -294,7 +307,8 @@ public inline fun String.codePointBefore(index: Int): Int = (this as java.lang.S
|
|||||||
* Returns the number of Unicode code points in the specified text range of this String.
|
* Returns the number of Unicode code points in the specified text range of this String.
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun String.codePointCount(beginIndex: Int, endIndex: Int): Int = (this as java.lang.String).codePointCount(beginIndex, endIndex)
|
public inline fun String.codePointCount(beginIndex: Int, endIndex: Int): Int =
|
||||||
|
(this as java.lang.String).codePointCount(beginIndex, endIndex)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares two strings lexicographically, optionally ignoring case differences.
|
* Compares two strings lexicographically, optionally ignoring case differences.
|
||||||
@@ -333,7 +347,8 @@ public actual fun CharSequence.isBlank(): Boolean = length == 0 || indices.all {
|
|||||||
* 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.
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun String.offsetByCodePoints(index: Int, codePointOffset: Int): Int = (this as java.lang.String).offsetByCodePoints(index, codePointOffset)
|
public inline fun String.offsetByCodePoints(index: Int, codePointOffset: Int): Int =
|
||||||
|
(this as java.lang.String).offsetByCodePoints(index, codePointOffset)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns `true` if the specified range in this char sequence is equal to the specified range in another char sequence.
|
* Returns `true` if the specified range in this char sequence is equal to the specified range in another char sequence.
|
||||||
|
|||||||
@@ -14,8 +14,10 @@ private interface FlagEnum {
|
|||||||
public val value: Int
|
public val value: Int
|
||||||
public val mask: Int
|
public val mask: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Iterable<FlagEnum>.toInt(): Int =
|
private fun Iterable<FlagEnum>.toInt(): Int =
|
||||||
this.fold(0, { value, option -> value or option.value })
|
this.fold(0, { value, option -> value or option.value })
|
||||||
|
|
||||||
private inline fun <reified T> fromInt(value: Int): Set<T> where T : FlagEnum, T : Enum<T> =
|
private inline fun <reified T> fromInt(value: Int): Set<T> where T : FlagEnum, T : Enum<T> =
|
||||||
Collections.unmodifiableSet(EnumSet.allOf(T::class.java).apply {
|
Collections.unmodifiableSet(EnumSet.allOf(T::class.java).apply {
|
||||||
retainAll { value and it.mask == it.value }
|
retainAll { value and it.mask == it.value }
|
||||||
@@ -117,13 +119,15 @@ internal constructor(private val nativePattern: Pattern) : Serializable {
|
|||||||
* @return An instance of [MatchResult] if match was found or `null` otherwise.
|
* @return An instance of [MatchResult] if match was found or `null` otherwise.
|
||||||
*/
|
*/
|
||||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||||
public actual 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].
|
||||||
*/
|
*/
|
||||||
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
|
||||||
public actual 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.
|
||||||
@@ -170,7 +174,8 @@ 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 actual 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)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -208,8 +213,10 @@ internal constructor(private val nativePattern: Pattern) : Serializable {
|
|||||||
actual companion object {
|
actual companion object {
|
||||||
/** Returns a literal regex for the specified [literal] string. */
|
/** Returns a literal regex for the specified [literal] string. */
|
||||||
public actual 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 actual 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 actual fun escapeReplacement(literal: String): String = Matcher.quoteReplacement(literal)
|
public actual fun escapeReplacement(literal: String): String = Matcher.quoteReplacement(literal)
|
||||||
|
|
||||||
@@ -247,6 +254,7 @@ private class MatcherMatchResult(private val matcher: Matcher, private val input
|
|||||||
else
|
else
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun get(name: String): MatchGroup? {
|
override fun get(name: String): MatchGroup? {
|
||||||
return IMPLEMENTATIONS.getMatchResultNamedGroup(matchResult, name)
|
return IMPLEMENTATIONS.getMatchResultNamedGroup(matchResult, name)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ package kotlin
|
|||||||
|
|
||||||
@PublishedApi
|
@PublishedApi
|
||||||
internal object _Assertions {
|
internal object _Assertions {
|
||||||
@JvmField @PublishedApi
|
@JvmField
|
||||||
|
@PublishedApi
|
||||||
internal val ENABLED: Boolean = javaClass.desiredAssertionStatus()
|
internal val ENABLED: Boolean = javaClass.desiredAssertionStatus()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,8 +70,7 @@ private class SynchronizedLazyImpl<out T>(initializer: () -> T, lock: Any? = nul
|
|||||||
val _v2 = _value
|
val _v2 = _value
|
||||||
if (_v2 !== UNINITIALIZED_VALUE) {
|
if (_v2 !== UNINITIALIZED_VALUE) {
|
||||||
@Suppress("UNCHECKED_CAST") (_v2 as T)
|
@Suppress("UNCHECKED_CAST") (_v2 as T)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
val typedValue = initializer!!()
|
val typedValue = initializer!!()
|
||||||
_value = typedValue
|
_value = typedValue
|
||||||
initializer = null
|
initializer = null
|
||||||
@@ -125,6 +124,7 @@ private class SafePublicationLazyImpl<out T>(initializer: () -> T) : Lazy<T>, Se
|
|||||||
private val valueUpdater = java.util.concurrent.atomic.AtomicReferenceFieldUpdater.newUpdater(
|
private val valueUpdater = java.util.concurrent.atomic.AtomicReferenceFieldUpdater.newUpdater(
|
||||||
SafePublicationLazyImpl::class.java,
|
SafePublicationLazyImpl::class.java,
|
||||||
Any::class.java,
|
Any::class.java,
|
||||||
"_value")
|
"_value"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -439,6 +439,7 @@ public actual inline fun sign(x: Double): Double = nativeMath.signum(x)
|
|||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
@InlineOnly
|
@InlineOnly
|
||||||
public actual 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.
|
||||||
*
|
*
|
||||||
@@ -524,6 +525,7 @@ public actual inline val Double.sign: Double get() = nativeMath.signum(this)
|
|||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
@InlineOnly
|
@InlineOnly
|
||||||
public actual 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.
|
||||||
*/
|
*/
|
||||||
@@ -551,6 +553,7 @@ public actual inline val Double.ulp: Double get() = nativeMath.ulp(this)
|
|||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
@InlineOnly
|
@InlineOnly
|
||||||
public actual 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.
|
||||||
*/
|
*/
|
||||||
@@ -599,8 +602,8 @@ public actual 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 actual 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)
|
||||||
|
|
||||||
|
|
||||||
// ================ Float Math ========================================
|
// ================ Float Math ========================================
|
||||||
@@ -963,6 +966,7 @@ public actual inline fun sign(x: Float): Float = nativeMath.signum(x)
|
|||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
@InlineOnly
|
@InlineOnly
|
||||||
public actual 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.
|
||||||
*
|
*
|
||||||
@@ -1048,6 +1052,7 @@ public actual inline val Float.sign: Float get() = nativeMath.signum(this)
|
|||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
@InlineOnly
|
@InlineOnly
|
||||||
public actual 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.
|
||||||
*/
|
*/
|
||||||
@@ -1075,6 +1080,7 @@ public inline val Float.ulp: Float get() = nativeMath.ulp(this)
|
|||||||
@SinceKotlin("1.2")
|
@SinceKotlin("1.2")
|
||||||
@InlineOnly
|
@InlineOnly
|
||||||
public inline fun Float.nextUp(): Float = nativeMath.nextUp(this)
|
public inline fun Float.nextUp(): Float = nativeMath.nextUp(this)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the [Float] value nearest to this value in direction of negative infinity.
|
* Returns the [Float] value nearest to this value in direction of negative infinity.
|
||||||
*/
|
*/
|
||||||
@@ -1105,7 +1111,8 @@ 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 actual 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].
|
||||||
|
|||||||
Reference in New Issue
Block a user