Drop Range<T> interface and its extensions.

This commit is contained in:
Ilya Gorbunov
2015-11-27 18:29:23 +03:00
parent face6d449b
commit e8621cb738
5 changed files with 5 additions and 438 deletions
-340
View File
@@ -67,15 +67,6 @@ public fun Short.`-until`(to: Short): ShortRange {
return ShortRange(this, to_)
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("intRangeContains")
public operator fun Range<Int>.contains(value: Byte): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -84,15 +75,6 @@ public operator fun ClosedRange<Int>.contains(value: Byte): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("longRangeContains")
public operator fun Range<Long>.contains(value: Byte): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -101,15 +83,6 @@ public operator fun ClosedRange<Long>.contains(value: Byte): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("shortRangeContains")
public operator fun Range<Short>.contains(value: Byte): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -118,15 +91,6 @@ public operator fun ClosedRange<Short>.contains(value: Byte): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("doubleRangeContains")
public operator fun Range<Double>.contains(value: Byte): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -135,15 +99,6 @@ public operator fun ClosedRange<Double>.contains(value: Byte): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("floatRangeContains")
public operator fun Range<Float>.contains(value: Byte): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -152,15 +107,6 @@ public operator fun ClosedRange<Float>.contains(value: Byte): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("intRangeContains")
public operator fun Range<Int>.contains(value: Double): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -169,15 +115,6 @@ public operator fun ClosedRange<Int>.contains(value: Double): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("longRangeContains")
public operator fun Range<Long>.contains(value: Double): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -186,15 +123,6 @@ public operator fun ClosedRange<Long>.contains(value: Double): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("byteRangeContains")
public operator fun Range<Byte>.contains(value: Double): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -203,15 +131,6 @@ public operator fun ClosedRange<Byte>.contains(value: Double): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("shortRangeContains")
public operator fun Range<Short>.contains(value: Double): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -220,15 +139,6 @@ public operator fun ClosedRange<Short>.contains(value: Double): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("floatRangeContains")
public operator fun Range<Float>.contains(value: Double): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -237,15 +147,6 @@ public operator fun ClosedRange<Float>.contains(value: Double): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("intRangeContains")
public operator fun Range<Int>.contains(value: Float): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -254,15 +155,6 @@ public operator fun ClosedRange<Int>.contains(value: Float): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("longRangeContains")
public operator fun Range<Long>.contains(value: Float): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -271,15 +163,6 @@ public operator fun ClosedRange<Long>.contains(value: Float): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("byteRangeContains")
public operator fun Range<Byte>.contains(value: Float): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -288,15 +171,6 @@ public operator fun ClosedRange<Byte>.contains(value: Float): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("shortRangeContains")
public operator fun Range<Short>.contains(value: Float): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -305,15 +179,6 @@ public operator fun ClosedRange<Short>.contains(value: Float): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("doubleRangeContains")
public operator fun Range<Double>.contains(value: Float): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -322,15 +187,6 @@ public operator fun ClosedRange<Double>.contains(value: Float): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("longRangeContains")
public operator fun Range<Long>.contains(value: Int): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -339,15 +195,6 @@ public operator fun ClosedRange<Long>.contains(value: Int): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("byteRangeContains")
public operator fun Range<Byte>.contains(value: Int): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -356,15 +203,6 @@ public operator fun ClosedRange<Byte>.contains(value: Int): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("shortRangeContains")
public operator fun Range<Short>.contains(value: Int): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -373,15 +211,6 @@ public operator fun ClosedRange<Short>.contains(value: Int): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("doubleRangeContains")
public operator fun Range<Double>.contains(value: Int): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -390,15 +219,6 @@ public operator fun ClosedRange<Double>.contains(value: Int): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("floatRangeContains")
public operator fun Range<Float>.contains(value: Int): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -407,15 +227,6 @@ public operator fun ClosedRange<Float>.contains(value: Int): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("intRangeContains")
public operator fun Range<Int>.contains(value: Long): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -424,15 +235,6 @@ public operator fun ClosedRange<Int>.contains(value: Long): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("byteRangeContains")
public operator fun Range<Byte>.contains(value: Long): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -441,15 +243,6 @@ public operator fun ClosedRange<Byte>.contains(value: Long): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("shortRangeContains")
public operator fun Range<Short>.contains(value: Long): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -458,15 +251,6 @@ public operator fun ClosedRange<Short>.contains(value: Long): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("doubleRangeContains")
public operator fun Range<Double>.contains(value: Long): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -475,15 +259,6 @@ public operator fun ClosedRange<Double>.contains(value: Long): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("floatRangeContains")
public operator fun Range<Float>.contains(value: Long): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -492,15 +267,6 @@ public operator fun ClosedRange<Float>.contains(value: Long): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("intRangeContains")
public operator fun Range<Int>.contains(value: Short): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -509,15 +275,6 @@ public operator fun ClosedRange<Int>.contains(value: Short): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("longRangeContains")
public operator fun Range<Long>.contains(value: Short): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -526,15 +283,6 @@ public operator fun ClosedRange<Long>.contains(value: Short): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("byteRangeContains")
public operator fun Range<Byte>.contains(value: Short): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -543,15 +291,6 @@ public operator fun ClosedRange<Byte>.contains(value: Short): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("doubleRangeContains")
public operator fun Range<Double>.contains(value: Short): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -560,15 +299,6 @@ public operator fun ClosedRange<Double>.contains(value: Short): Boolean {
return start <= value && value <= endInclusive
}
/**
* Checks if the specified [value] belongs to this range.
*/
@Deprecated("Range<T> is deprecated. Use ClosedRange<T> instead.")
@kotlin.jvm.JvmName("floatRangeContains")
public operator fun Range<Float>.contains(value: Short): Boolean {
return start <= value && value <= end
}
/**
* Checks if the specified [value] belongs to this range.
*/
@@ -1286,73 +1016,3 @@ public fun Long.coerceIn(range: ClosedRange<Long>): Long {
return if (this < range.start) range.start else if (this > range.endInclusive) range.endInclusive 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("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
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("Range<T> is deprecated. Use ClosedRange<T> instead.")
public fun Byte.coerceIn(range: Range<Byte>): Byte {
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("Range<T> is deprecated. Use ClosedRange<T> instead.")
public fun Int.coerceIn(range: Range<Int>): Int {
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("Range<T> is deprecated. Use ClosedRange<T> instead.")
public fun Long.coerceIn(range: Range<Long>): Long {
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("Range<T> is deprecated. Use ClosedRange<T> instead.")
public fun Short.coerceIn(range: Range<Short>): Short {
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("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
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("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
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
}