Deprecate Double, Float and Comparable range implementations.
This commit is contained in:
@@ -39,7 +39,9 @@ public operator fun Range<Short>.contains(item: Byte): Boolean {
|
||||
/**
|
||||
* Checks if the specified [item] belongs to this range.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@kotlin.jvm.JvmName("doubleRangeContains")
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public operator fun Range<Double>.contains(item: Byte): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
@@ -47,7 +49,9 @@ public operator fun Range<Double>.contains(item: Byte): Boolean {
|
||||
/**
|
||||
* Checks if the specified [item] belongs to this range.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@kotlin.jvm.JvmName("floatRangeContains")
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public operator fun Range<Float>.contains(item: Byte): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
@@ -87,7 +91,9 @@ public operator fun Range<Short>.contains(item: Double): Boolean {
|
||||
/**
|
||||
* Checks if the specified [item] belongs to this range.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@kotlin.jvm.JvmName("floatRangeContains")
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public operator fun Range<Float>.contains(item: Double): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
@@ -127,7 +133,9 @@ public operator fun Range<Short>.contains(item: Float): Boolean {
|
||||
/**
|
||||
* Checks if the specified [item] belongs to this range.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@kotlin.jvm.JvmName("doubleRangeContains")
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public operator fun Range<Double>.contains(item: Float): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
@@ -159,7 +167,9 @@ public operator fun Range<Short>.contains(item: Int): Boolean {
|
||||
/**
|
||||
* Checks if the specified [item] belongs to this range.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@kotlin.jvm.JvmName("doubleRangeContains")
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public operator fun Range<Double>.contains(item: Int): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
@@ -167,7 +177,9 @@ public operator fun Range<Double>.contains(item: Int): Boolean {
|
||||
/**
|
||||
* Checks if the specified [item] belongs to this range.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@kotlin.jvm.JvmName("floatRangeContains")
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public operator fun Range<Float>.contains(item: Int): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
@@ -199,7 +211,9 @@ public operator fun Range<Short>.contains(item: Long): Boolean {
|
||||
/**
|
||||
* Checks if the specified [item] belongs to this range.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@kotlin.jvm.JvmName("doubleRangeContains")
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public operator fun Range<Double>.contains(item: Long): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
@@ -207,7 +221,9 @@ public operator fun Range<Double>.contains(item: Long): Boolean {
|
||||
/**
|
||||
* Checks if the specified [item] belongs to this range.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@kotlin.jvm.JvmName("floatRangeContains")
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public operator fun Range<Float>.contains(item: Long): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
@@ -239,7 +255,9 @@ public operator fun Range<Byte>.contains(item: Short): Boolean {
|
||||
/**
|
||||
* Checks if the specified [item] belongs to this range.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@kotlin.jvm.JvmName("doubleRangeContains")
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public operator fun Range<Double>.contains(item: Short): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
@@ -247,7 +265,9 @@ public operator fun Range<Double>.contains(item: Short): Boolean {
|
||||
/**
|
||||
* Checks if the specified [item] belongs to this range.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@kotlin.jvm.JvmName("floatRangeContains")
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public operator fun Range<Float>.contains(item: Short): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
@@ -288,6 +308,8 @@ public infix fun Short.downTo(to: Byte): ShortProgression {
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun Double.downTo(to: Byte): DoubleProgression {
|
||||
return DoubleProgression(this, to.toDouble(), -1.0)
|
||||
}
|
||||
@@ -296,6 +318,8 @@ public infix fun Double.downTo(to: Byte): DoubleProgression {
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun Float.downTo(to: Byte): FloatProgression {
|
||||
return FloatProgression(this, to.toFloat(), -1.0F)
|
||||
}
|
||||
@@ -312,6 +336,8 @@ public infix fun Char.downTo(to: Char): CharProgression {
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun Int.downTo(to: Double): DoubleProgression {
|
||||
return DoubleProgression(this.toDouble(), to, -1.0)
|
||||
}
|
||||
@@ -320,6 +346,8 @@ public infix fun Int.downTo(to: Double): DoubleProgression {
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun Long.downTo(to: Double): DoubleProgression {
|
||||
return DoubleProgression(this.toDouble(), to, -1.0)
|
||||
}
|
||||
@@ -328,6 +356,8 @@ public infix fun Long.downTo(to: Double): DoubleProgression {
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun Byte.downTo(to: Double): DoubleProgression {
|
||||
return DoubleProgression(this.toDouble(), to, -1.0)
|
||||
}
|
||||
@@ -336,6 +366,8 @@ public infix fun Byte.downTo(to: Double): DoubleProgression {
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun Short.downTo(to: Double): DoubleProgression {
|
||||
return DoubleProgression(this.toDouble(), to, -1.0)
|
||||
}
|
||||
@@ -344,6 +376,8 @@ public infix fun Short.downTo(to: Double): DoubleProgression {
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun Double.downTo(to: Double): DoubleProgression {
|
||||
return DoubleProgression(this, to, -1.0)
|
||||
}
|
||||
@@ -352,6 +386,8 @@ public infix fun Double.downTo(to: Double): DoubleProgression {
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun Float.downTo(to: Double): DoubleProgression {
|
||||
return DoubleProgression(this.toDouble(), to, -1.0)
|
||||
}
|
||||
@@ -360,6 +396,8 @@ public infix fun Float.downTo(to: Double): DoubleProgression {
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun Int.downTo(to: Float): FloatProgression {
|
||||
return FloatProgression(this.toFloat(), to, -1.0F)
|
||||
}
|
||||
@@ -368,6 +406,8 @@ public infix fun Int.downTo(to: Float): FloatProgression {
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun Long.downTo(to: Float): FloatProgression {
|
||||
return FloatProgression(this.toFloat(), to, -1.0F)
|
||||
}
|
||||
@@ -376,6 +416,8 @@ public infix fun Long.downTo(to: Float): FloatProgression {
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun Byte.downTo(to: Float): FloatProgression {
|
||||
return FloatProgression(this.toFloat(), to, -1.0F)
|
||||
}
|
||||
@@ -384,6 +426,8 @@ public infix fun Byte.downTo(to: Float): FloatProgression {
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun Short.downTo(to: Float): FloatProgression {
|
||||
return FloatProgression(this.toFloat(), to, -1.0F)
|
||||
}
|
||||
@@ -392,6 +436,8 @@ public infix fun Short.downTo(to: Float): FloatProgression {
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun Double.downTo(to: Float): DoubleProgression {
|
||||
return DoubleProgression(this, to.toDouble(), -1.0)
|
||||
}
|
||||
@@ -400,6 +446,8 @@ public infix fun Double.downTo(to: Float): DoubleProgression {
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun Float.downTo(to: Float): FloatProgression {
|
||||
return FloatProgression(this, to, -1.0F)
|
||||
}
|
||||
@@ -440,6 +488,8 @@ public infix fun Short.downTo(to: Int): IntProgression {
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun Double.downTo(to: Int): DoubleProgression {
|
||||
return DoubleProgression(this, to.toDouble(), -1.0)
|
||||
}
|
||||
@@ -448,6 +498,8 @@ public infix fun Double.downTo(to: Int): DoubleProgression {
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun Float.downTo(to: Int): FloatProgression {
|
||||
return FloatProgression(this, to.toFloat(), -1.0F)
|
||||
}
|
||||
@@ -488,6 +540,8 @@ public infix fun Short.downTo(to: Long): LongProgression {
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun Double.downTo(to: Long): DoubleProgression {
|
||||
return DoubleProgression(this, to.toDouble(), -1.0)
|
||||
}
|
||||
@@ -496,6 +550,8 @@ public infix fun Double.downTo(to: Long): DoubleProgression {
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun Float.downTo(to: Long): FloatProgression {
|
||||
return FloatProgression(this, to.toFloat(), -1.0F)
|
||||
}
|
||||
@@ -536,6 +592,8 @@ public infix fun Short.downTo(to: Short): ShortProgression {
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun Double.downTo(to: Short): DoubleProgression {
|
||||
return DoubleProgression(this, to.toDouble(), -1.0)
|
||||
}
|
||||
@@ -544,6 +602,8 @@ public infix fun Double.downTo(to: Short): DoubleProgression {
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun Float.downTo(to: Short): FloatProgression {
|
||||
return FloatProgression(this, to.toFloat(), -1.0F)
|
||||
}
|
||||
@@ -562,20 +622,6 @@ public fun CharProgression.reversed(): CharProgression {
|
||||
return CharProgression(end, start, -increment)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range in the opposite direction with the same step.
|
||||
*/
|
||||
public fun DoubleProgression.reversed(): DoubleProgression {
|
||||
return DoubleProgression(end, start, -increment)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range in the opposite direction with the same step.
|
||||
*/
|
||||
public fun FloatProgression.reversed(): FloatProgression {
|
||||
return FloatProgression(end, start, -increment)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range in the opposite direction with the same step.
|
||||
*/
|
||||
@@ -611,20 +657,6 @@ public fun CharRange.reversed(): CharProgression {
|
||||
return CharProgression(end, start, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over this range in reverse direction.
|
||||
*/
|
||||
public fun DoubleRange.reversed(): DoubleProgression {
|
||||
return DoubleProgression(end, start, -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over this range in reverse direction.
|
||||
*/
|
||||
public fun FloatRange.reversed(): FloatProgression {
|
||||
return FloatProgression(end, start, -1.0f)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over this range in reverse direction.
|
||||
*/
|
||||
@@ -646,6 +678,42 @@ public fun ShortRange.reversed(): ShortProgression {
|
||||
return ShortProgression(end, start, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range in the opposite direction with the same step.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public fun DoubleProgression.reversed(): DoubleProgression {
|
||||
return DoubleProgression(end, start, -increment)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range in the opposite direction with the same step.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public fun FloatProgression.reversed(): FloatProgression {
|
||||
return FloatProgression(end, start, -increment)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over this range in reverse direction.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public fun DoubleRange.reversed(): DoubleProgression {
|
||||
return DoubleProgression(end, start, -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over this range in reverse direction.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public fun FloatRange.reversed(): FloatProgression {
|
||||
return FloatProgression(end, start, -1.0f)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range with the given step.
|
||||
*/
|
||||
@@ -662,22 +730,6 @@ public infix fun CharProgression.step(step: Int): CharProgression {
|
||||
return CharProgression(start, end, if (increment > 0) step else -step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range with the given step.
|
||||
*/
|
||||
public infix fun DoubleProgression.step(step: Double): DoubleProgression {
|
||||
checkStepIsPositive(step > 0, step)
|
||||
return DoubleProgression(start, end, if (increment > 0) step else -step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range with the given step.
|
||||
*/
|
||||
public infix fun FloatProgression.step(step: Float): FloatProgression {
|
||||
checkStepIsPositive(step > 0, step)
|
||||
return FloatProgression(start, end, if (increment > 0) step else -step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range with the given step.
|
||||
*/
|
||||
@@ -718,24 +770,6 @@ public infix fun CharRange.step(step: Int): CharProgression {
|
||||
return CharProgression(start, end, step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over this range with given step.
|
||||
*/
|
||||
public infix fun DoubleRange.step(step: Double): DoubleProgression {
|
||||
if (step.isNaN()) throw IllegalArgumentException("Step must not be NaN.")
|
||||
checkStepIsPositive(step > 0, step)
|
||||
return DoubleProgression(start, end, step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over this range with given step.
|
||||
*/
|
||||
public infix fun FloatRange.step(step: Float): FloatProgression {
|
||||
if (step.isNaN()) throw IllegalArgumentException("Step must not be NaN.")
|
||||
checkStepIsPositive(step > 0, step)
|
||||
return FloatProgression(start, end, step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over this range with given step.
|
||||
*/
|
||||
@@ -760,6 +794,48 @@ public infix fun ShortRange.step(step: Int): ShortProgression {
|
||||
return ShortProgression(start, end, step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range with the given step.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun DoubleProgression.step(step: Double): DoubleProgression {
|
||||
checkStepIsPositive(step > 0, step)
|
||||
return DoubleProgression(start, end, if (increment > 0) step else -step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range with the given step.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun FloatProgression.step(step: Float): FloatProgression {
|
||||
checkStepIsPositive(step > 0, step)
|
||||
return FloatProgression(start, end, if (increment > 0) step else -step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over this range with given step.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun DoubleRange.step(step: Double): DoubleProgression {
|
||||
if (step.isNaN()) throw IllegalArgumentException("Step must not be NaN.")
|
||||
checkStepIsPositive(step > 0, step)
|
||||
return DoubleProgression(start, end, step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over this range with given step.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public infix fun FloatRange.step(step: Float): FloatProgression {
|
||||
if (step.isNaN()) throw IllegalArgumentException("Step must not be NaN.")
|
||||
checkStepIsPositive(step > 0, step)
|
||||
return FloatProgression(start, end, step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*/
|
||||
@@ -1143,15 +1219,6 @@ public fun Short.coerceIn(minimumValue: Short?, maximumValue: Short?): Short {
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified [range].
|
||||
* @return this value if it's in the [range], or range.start if this value is less than range.start, or range.end if this value is greater than range.end.
|
||||
*/
|
||||
public fun <T: Comparable<T>> T.coerceIn(range: Range<T>): T {
|
||||
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")
|
||||
return if (this < range.start) range.start else if (this > range.end) range.end else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified [range].
|
||||
* @return this value if it's in the [range], or range.start if this value is less than range.start, or range.end if this value is greater than range.end.
|
||||
@@ -1161,24 +1228,6 @@ public fun Byte.coerceIn(range: Range<Byte>): Byte {
|
||||
return if (this < range.start) range.start else if (this > range.end) range.end else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified [range].
|
||||
* @return this value if it's in the [range], or range.start if this value is less than range.start, or range.end if this value is greater than range.end.
|
||||
*/
|
||||
public fun Double.coerceIn(range: Range<Double>): Double {
|
||||
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")
|
||||
return if (this < range.start) range.start else if (this > range.end) range.end else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified [range].
|
||||
* @return this value if it's in the [range], or range.start if this value is less than range.start, or range.end if this value is greater than range.end.
|
||||
*/
|
||||
public fun Float.coerceIn(range: Range<Float>): Float {
|
||||
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")
|
||||
return if (this < range.start) range.start else if (this > range.end) range.end else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified [range].
|
||||
* @return this value if it's in the [range], or range.start if this value is less than range.start, or range.end if this value is greater than range.end.
|
||||
@@ -1206,3 +1255,33 @@ public fun Short.coerceIn(range: Range<Short>): Short {
|
||||
return if (this < range.start) range.start else if (this > range.end) range.end else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified [range].
|
||||
* @return this value if it's in the [range], or range.start if this value is less than range.start, or range.end if this value is greater than range.end.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
public fun <T: Comparable<T>> T.coerceIn(range: Range<T>): T {
|
||||
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")
|
||||
return if (this < range.start) range.start else if (this > range.end) range.end else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified [range].
|
||||
* @return this value if it's in the [range], or range.start if this value is less than range.start, or range.end if this value is greater than range.end.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
public fun Double.coerceIn(range: Range<Double>): Double {
|
||||
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")
|
||||
return if (this < range.start) range.start else if (this > range.end) range.end else this
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that this value lies in the specified [range].
|
||||
* @return this value if it's in the [range], or range.start if this value is less than range.start, or range.end if this value is greater than range.end.
|
||||
*/
|
||||
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR)
|
||||
public fun Float.coerceIn(range: Range<Float>): Float {
|
||||
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")
|
||||
return if (this < range.start) range.start else if (this > range.end) range.end else this
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user