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")
public operator fun ClosedFloatingPointRange.component1(): Double =
	start


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy