Drop Range<T> interface and its extensions.
This commit is contained in:
@@ -20,45 +20,12 @@ package kotlin.ranges
|
||||
* Represents a range of values (for example, numbers or characters).
|
||||
* See the [Kotlin language documentation](http://kotlinlang.org/docs/reference/ranges.html) for more information.
|
||||
*/
|
||||
@Deprecated("This range has unclear inclusiveness of end value. Use ClosedRange instead.", ReplaceWith("ClosedRange<T>"))
|
||||
public interface Range<T : Comparable<T>> {
|
||||
public interface ClosedRange<T: Comparable<T>> {
|
||||
/**
|
||||
* The minimum value in the range.
|
||||
*/
|
||||
public val start: T
|
||||
|
||||
/**
|
||||
* The maximum value in the range (inclusive).
|
||||
*/
|
||||
public val end: T
|
||||
|
||||
/**
|
||||
* Checks if the specified [value] belongs to the range.
|
||||
*/
|
||||
public operator fun contains(value: T): Boolean
|
||||
|
||||
/**
|
||||
* Checks if the range is empty.
|
||||
*/
|
||||
public fun isEmpty(): Boolean = start > end
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a range of values (for example, numbers or characters).
|
||||
* See the [Kotlin language documentation](http://kotlinlang.org/docs/reference/ranges.html) for more information.
|
||||
*/
|
||||
public interface ClosedRange<T: Comparable<T>> : Range<T> {
|
||||
/**
|
||||
* The minimum value in the range.
|
||||
*/
|
||||
public override val start: T
|
||||
|
||||
/**
|
||||
* The maximum value in the range (inclusive).
|
||||
*/
|
||||
@Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive"))
|
||||
public override val end: T get() = endInclusive
|
||||
|
||||
/**
|
||||
* The maximum value in the range (inclusive).
|
||||
*/
|
||||
@@ -67,10 +34,10 @@ public interface ClosedRange<T: Comparable<T>> : Range<T> {
|
||||
/**
|
||||
* Checks whether the specified [value] belongs to the range.
|
||||
*/
|
||||
public override operator fun contains(value: T): Boolean = value >= start && value <= endInclusive
|
||||
public operator fun contains(value: T): Boolean = value >= start && value <= endInclusive
|
||||
|
||||
/**
|
||||
* Checks whether the range is empty.
|
||||
*/
|
||||
public override fun isEmpty(): Boolean = start > endInclusive
|
||||
public fun isEmpty(): Boolean = start > endInclusive
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user