Rename ClosedComparableRange to ClosedFloatingPointRange

This commit is contained in:
Ilya Gorbunov
2016-12-16 03:14:17 +03:00
parent 919c77b950
commit 10f8e70322
10 changed files with 31 additions and 31 deletions
@@ -868,7 +868,7 @@ public fun Double.coerceIn(minimumValue: Double, maximumValue: Double): Double {
*
* @return this value if it's in the [range], or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`.
*/
public fun <T: Comparable<T>> T.coerceIn(range: ClosedComparableRange<T>): T {
public fun <T: Comparable<T>> T.coerceIn(range: ClosedFloatingPointRange<T>): T {
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")
return when {
// this < start equiv to this <= start && !(this >= start)
@@ -885,7 +885,7 @@ public fun <T: Comparable<T>> T.coerceIn(range: ClosedComparableRange<T>): T {
* @return this value if it's in the [range], or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`.
*/
public fun <T: Comparable<T>> T.coerceIn(range: ClosedRange<T>): T {
if (range is ClosedComparableRange) {
if (range is ClosedFloatingPointRange) {
return this.coerceIn<T>(range)
}
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")
@@ -902,7 +902,7 @@ public fun <T: Comparable<T>> T.coerceIn(range: ClosedRange<T>): T {
* @return this value if it's in the [range], or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`.
*/
public fun Int.coerceIn(range: ClosedRange<Int>): Int {
if (range is ClosedComparableRange) {
if (range is ClosedFloatingPointRange) {
return this.coerceIn<Int>(range)
}
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")
@@ -919,7 +919,7 @@ public fun Int.coerceIn(range: ClosedRange<Int>): Int {
* @return this value if it's in the [range], or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`.
*/
public fun Long.coerceIn(range: ClosedRange<Long>): Long {
if (range is ClosedComparableRange) {
if (range is ClosedFloatingPointRange) {
return this.coerceIn<Long>(range)
}
if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.")