All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.extensions.ClosedFloatingPointRange.kt Maven / Gradle / Ivy

package io.fluidsonic.stdlib

import kotlin.jvm.*
import kotlin.math.*


@JvmName("component1Double")
operator fun ClosedFloatingPointRange.component1() =
	start


@JvmName("component1Float")
operator fun ClosedFloatingPointRange.component1() =
	start


@JvmName("component2Double")
operator fun ClosedFloatingPointRange.component2() =
	endInclusive


@JvmName("component2Float")
operator fun ClosedFloatingPointRange.component2() =
	endInclusive


@JvmName("flippedDouble")
fun ClosedFloatingPointRange.flipped() =
	endInclusive .. start


@JvmName("flippedFloat")
fun ClosedFloatingPointRange.flipped() =
	endInclusive .. start


@JvmName("mapFloatBounds")
fun > ClosedFloatingPointRange.mapBounds(transform: (Float) -> R) =
	transform(start) .. transform(endInclusive)


@JvmName("mapDoubleBounds")
fun > ClosedFloatingPointRange.mapBounds(transform: (Double) -> R) =
	transform(start) .. transform(endInclusive)


@JvmName("mapFloatBoundsToDouble")
fun ClosedFloatingPointRange.mapBounds(transform: (Float) -> Double) =
	transform(start) .. transform(endInclusive)


@JvmName("mapDoubleBoundsToDouble")
fun ClosedFloatingPointRange.mapBounds(transform: (Double) -> Double) =
	transform(start) .. transform(endInclusive)


@JvmName("mapFloatBoundsToFloat")
fun ClosedFloatingPointRange.mapBounds(transform: (Float) -> Float) =
	transform(start) .. transform(endInclusive)


@JvmName("mapDoubleBoundsToFloat")
fun ClosedFloatingPointRange.mapBounds(transform: (Double) -> Float) =
	transform(start) .. transform(endInclusive)


@JvmName("mapFloatBounds")
fun ClosedFloatingPointRange.mapBounds(transform: (Float) -> Int) =
	transform(start) .. transform(endInclusive)


@JvmName("mapDoubleBounds")
fun ClosedFloatingPointRange.mapBounds(transform: (Double) -> Int) =
	transform(start) .. transform(endInclusive)


@JvmName("mapFloatBounds")
fun ClosedFloatingPointRange.mapBounds(transform: (Float) -> Long) =
	transform(start) .. transform(endInclusive)


@JvmName("mapDoubleBounds")
fun ClosedFloatingPointRange.mapBounds(transform: (Double) -> Long) =
	transform(start) .. transform(endInclusive)


@ExperimentalUnsignedTypes
@JvmName("mapFloatBounds")
fun ClosedFloatingPointRange.mapBounds(transform: (Float) -> UInt) =
	transform(start) .. transform(endInclusive)


@ExperimentalUnsignedTypes
@JvmName("mapDoubleBounds")
fun ClosedFloatingPointRange.mapBounds(transform: (Double) -> UInt) =
	transform(start) .. transform(endInclusive)


@ExperimentalUnsignedTypes
@JvmName("mapFloatBounds")
fun ClosedFloatingPointRange.mapBounds(transform: (Float) -> ULong) =
	transform(start) .. transform(endInclusive)


@ExperimentalUnsignedTypes
@JvmName("mapDoubleBounds")
fun ClosedFloatingPointRange.mapBounds(transform: (Double) -> ULong) =
	transform(start) .. transform(endInclusive)


@JvmName("intersectionFloat")
fun ClosedFloatingPointRange.intersection(other: ClosedFloatingPointRange) =
	overlaps(other).thenTake { max(start, other.start) rangeToExcluding min(endInclusive, other.endInclusive) }


@JvmName("intersectionDouble")
fun ClosedFloatingPointRange.intersection(other: ClosedFloatingPointRange) =
	overlaps(other).thenTake { max(start, other.start) rangeToExcluding min(endInclusive, other.endInclusive) }


@JvmName("overlapsFloat")
fun ClosedFloatingPointRange.overlaps(other: ClosedFloatingPointRange) =
	contains(other.start) || other.contains(start)


@JvmName("overlapsDouble")
fun ClosedFloatingPointRange.overlaps(other: ClosedFloatingPointRange) =
	contains(other.start) || other.contains(start)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy