Drop Progression<T> and its deprecated properties: start, end, increment.

Drop deprecated range extensions.
Make progression constructors private.
This commit is contained in:
Ilya Gorbunov
2016-01-14 20:19:52 +03:00
parent 6dd8470835
commit 91f4cf0ebc
15 changed files with 45 additions and 257 deletions
@@ -52,13 +52,12 @@ class GenerateProgressions(out: PrintWriter) : BuiltInsSourceGenerator(out) {
* A progression of values of type `$t`.
*/
public open class $progression
@Deprecated("This constructor will become private soon. Use $progression.fromClosedRange() instead.", ReplaceWith("$progression.fromClosedRange(start, endInclusive, step)"))
public constructor
internal constructor
(
start: $t,
endInclusive: $t,
step: $incrementType
) : Progression<$t> /*, Iterable<$t> */ {
) : Iterable<$t> {
init {
$checkZero
}
@@ -78,19 +77,6 @@ public open class $progression
*/
public val step: $incrementType = step
@Deprecated("Use 'first' property instead.", ReplaceWith("first"))
public override val start: $t get() = first
/**
* The end value of the progression (inclusive).
*/
@Deprecated("Use 'last' property instead.")
public override val end: $t = endInclusive
@Deprecated("Use 'step' property instead.", ReplaceWith("step"))
public override val increment: $incrementType get() = step
override fun iterator(): ${t}Iterator = ${t}ProgressionIterator(first, last, step)
/** Checks if the progression is empty. */
@@ -39,33 +39,30 @@ class GenerateRanges(out: PrintWriter) : BuiltInsSourceGenerator(out) {
val hashCode = when (kind) {
CHAR -> "=\n" +
" if (isEmpty()) -1 else (31 * start.toInt() + endInclusive.toInt())"
" if (isEmpty()) -1 else (31 * first.toInt() + last.toInt())"
INT -> "=\n" +
" if (isEmpty()) -1 else (31 * start + endInclusive)"
" if (isEmpty()) -1 else (31 * first + last)"
LONG -> "=\n" +
" if (isEmpty()) -1 else (31 * ${hashLong("start")} + ${hashLong("endInclusive")}).toInt()"
" if (isEmpty()) -1 else (31 * ${hashLong("first")} + ${hashLong("last")}).toInt()"
}
val toString = "\"\$start..\$endInclusive\""
val toString = "\"\$first..\$last\""
out.println(
"""/**
* A range of values of type `$t`.
*/
public class $range(start: $t, endInclusive: $t) : ${t}Progression(start, endInclusive, $increment), ClosedRange<$t> {
@Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive"))
override val end: $t get() = endInclusive
override val start: $t get() = first
override val endInclusive: $t get() = last
override fun contains(value: $t): Boolean = start <= value && value <= endInclusive
override fun contains(value: $t): Boolean = first <= value && value <= last
override fun isEmpty(): Boolean = start > endInclusive
override fun isEmpty(): Boolean = first > last
override fun equals(other: Any?): Boolean =
other is $range && (isEmpty() && other.isEmpty() ||
${compare("start")} && ${compare("endInclusive")})
${compare("first")} && ${compare("last")})
override fun hashCode(): Int $hashCode