commonMain.extensions.IntRange.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fluid-stdlib-tvosx64 Show documentation
Show all versions of fluid-stdlib-tvosx64 Show documentation
Potentially useful Kotlin standard library additions
package io.fluidsonic.stdlib
import kotlin.jvm.*
import kotlin.math.*
public operator fun IntRange.component1(): Int =
first
public operator fun IntRange.component2(): Int =
last
public fun IntRange.flipped(): IntRange =
last .. first
public fun > IntRange.mapBounds(transform: (Int) -> R): ClosedRange =
transform(first) .. transform(last)
@JvmName("mapBoundsToDouble")
public fun IntRange.mapBounds(transform: (Int) -> Double): ClosedFloatingPointRange =
transform(first) .. transform(last)
@JvmName("mapBoundsToFloat")
public fun IntRange.mapBounds(transform: (Int) -> Float): ClosedFloatingPointRange =
transform(first) .. transform(last)
public fun IntRange.mapBounds(transform: (Int) -> Int): IntRange =
transform(first) .. transform(last)
public fun IntRange.mapBounds(transform: (Int) -> Long): LongRange =
transform(first) .. transform(last)
public fun IntRange.mapBounds(transform: (Int) -> UInt): UIntRange =
transform(first) .. transform(last)
public fun IntRange.mapBounds(transform: (Int) -> ULong): ULongRange =
transform(first) .. transform(last)
public fun IntRange.intersection(other: IntRange): HalfOpenIntRange? =
overlaps(other).thenTake { max(first, other.first) rangeToExcluding min(last, other.last) }
public fun IntRange.overlaps(other: IntRange): Boolean =
contains(other.first) || other.contains(first)
© 2015 - 2025 Weber Informatics LLC | Privacy Policy