Introduce 'step' property in progressions instead of 'increment'

This commit is contained in:
Ilya Gorbunov
2015-11-26 23:43:31 +03:00
parent b8d0685b71
commit 661e288362
10 changed files with 309 additions and 226 deletions
+55 -35
View File
@@ -129,17 +129,19 @@ public abstract class ByteIterator : kotlin.Iterator<kotlin.Byte> {
}
@kotlin.Deprecated(level = DeprecationLevel.WARNING, message = "Use IntProgression instead.", replaceWith = kotlin.ReplaceWith(expression = "IntProgression", imports = {})) public open class ByteProgression : kotlin.Progression<kotlin.Byte> {
/*primary*/ @kotlin.Deprecated(message = "This constructor will become private soon. Use ByteProgression.fromClosedRange() instead.", replaceWith = kotlin.ReplaceWith(expression = "ByteProgression.fromClosedRange(start, endInclusive, increment)", imports = {})) public constructor ByteProgression(/*0*/ start: kotlin.Byte, /*1*/ endInclusive: kotlin.Byte, /*2*/ increment: kotlin.Int)
/*primary*/ @kotlin.Deprecated(message = "This constructor will become private soon. Use ByteProgression.fromClosedRange() instead.", replaceWith = kotlin.ReplaceWith(expression = "ByteProgression.fromClosedRange(start, endInclusive, step)", imports = {})) public constructor ByteProgression(/*0*/ start: kotlin.Byte, /*1*/ endInclusive: kotlin.Byte, /*2*/ step: kotlin.Int)
@kotlin.Deprecated(message = "Use 'last' property instead.") public open override /*1*/ val end: kotlin.Byte
public open override /*1*/ fun <get-end>(): kotlin.Byte
public final val first: kotlin.Byte
public final fun <get-first>(): kotlin.Byte
public open override /*1*/ val increment: kotlin.Int
@kotlin.Deprecated(message = "Use 'step' property instead.", replaceWith = kotlin.ReplaceWith(expression = "step", imports = {})) public open override /*1*/ val increment: kotlin.Int
public open override /*1*/ fun <get-increment>(): kotlin.Int
public final val last: kotlin.Byte
public final fun <get-last>(): kotlin.Byte
@kotlin.Deprecated(message = "Use first instead.", replaceWith = kotlin.ReplaceWith(expression = "first", imports = {})) public open override /*1*/ val start: kotlin.Byte
@kotlin.Deprecated(message = "Use 'first' property instead.", replaceWith = kotlin.ReplaceWith(expression = "first", imports = {})) public open override /*1*/ val start: kotlin.Byte
public open override /*1*/ fun <get-start>(): kotlin.Byte
public final val step: kotlin.Int
public final fun <get-step>(): kotlin.Int
public open fun isEmpty(): kotlin.Boolean
public open override /*1*/ fun iterator(): kotlin.ByteIterator
@@ -150,17 +152,17 @@ public abstract class ByteIterator : kotlin.Iterator<kotlin.Byte> {
}
internal final class ByteProgressionIterator : kotlin.ByteIterator {
/*primary*/ public constructor ByteProgressionIterator(/*0*/ first: kotlin.Byte, /*1*/ last: kotlin.Byte, /*2*/ increment: kotlin.Int)
/*primary*/ public constructor ByteProgressionIterator(/*0*/ first: kotlin.Byte, /*1*/ last: kotlin.Byte, /*2*/ step: kotlin.Int)
private final val finalElement: kotlin.Int
private final fun <get-finalElement>(): kotlin.Int
private final var hasNext: kotlin.Boolean
private final fun <get-hasNext>(): kotlin.Boolean
private final fun <set-hasNext>(/*0*/ <set-?>: kotlin.Boolean): kotlin.Unit
public final val increment: kotlin.Int
public final fun <get-increment>(): kotlin.Int
private final var next: kotlin.Int
private final fun <get-next>(): kotlin.Int
private final fun <set-next>(/*0*/ <set-?>: kotlin.Int): kotlin.Unit
public final val step: kotlin.Int
public final fun <get-step>(): kotlin.Int
public open override /*1*/ fun hasNext(): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun next(): kotlin.Byte
public open override /*1*/ fun nextByte(): kotlin.Byte
@@ -174,12 +176,14 @@ internal final class ByteProgressionIterator : kotlin.ByteIterator {
public open override /*1*/ fun <get-endInclusive>(): kotlin.Byte
public final override /*1*/ /*fake_override*/ val first: kotlin.Byte
public final override /*1*/ /*fake_override*/ fun <get-first>(): kotlin.Byte
public open override /*1*/ /*fake_override*/ val increment: kotlin.Int
@kotlin.Deprecated(message = "Use 'step' property instead.", replaceWith = kotlin.ReplaceWith(expression = "step", imports = {})) public open override /*1*/ /*fake_override*/ val increment: kotlin.Int
public open override /*1*/ /*fake_override*/ fun <get-increment>(): kotlin.Int
public final override /*1*/ /*fake_override*/ val last: kotlin.Byte
public final override /*1*/ /*fake_override*/ fun <get-last>(): kotlin.Byte
public open override /*2*/ val start: kotlin.Byte
public open override /*2*/ fun <get-start>(): kotlin.Byte
public final override /*1*/ /*fake_override*/ val step: kotlin.Int
public final override /*1*/ /*fake_override*/ fun <get-step>(): kotlin.Int
public open override /*1*/ fun contains(/*0*/ value: kotlin.Byte): kotlin.Boolean
public open override /*2*/ fun isEmpty(): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.ByteIterator
@@ -231,17 +235,19 @@ public abstract class CharIterator : kotlin.Iterator<kotlin.Char> {
}
public open class CharProgression : kotlin.Progression<kotlin.Char> {
/*primary*/ @kotlin.Deprecated(message = "This constructor will become private soon. Use CharProgression.fromClosedRange() instead.", replaceWith = kotlin.ReplaceWith(expression = "CharProgression.fromClosedRange(start, endInclusive, increment)", imports = {})) public constructor CharProgression(/*0*/ start: kotlin.Char, /*1*/ endInclusive: kotlin.Char, /*2*/ increment: kotlin.Int)
/*primary*/ @kotlin.Deprecated(message = "This constructor will become private soon. Use CharProgression.fromClosedRange() instead.", replaceWith = kotlin.ReplaceWith(expression = "CharProgression.fromClosedRange(start, endInclusive, step)", imports = {})) public constructor CharProgression(/*0*/ start: kotlin.Char, /*1*/ endInclusive: kotlin.Char, /*2*/ step: kotlin.Int)
@kotlin.Deprecated(message = "Use 'last' property instead.") public open override /*1*/ val end: kotlin.Char
public open override /*1*/ fun <get-end>(): kotlin.Char
public final val first: kotlin.Char
public final fun <get-first>(): kotlin.Char
public open override /*1*/ val increment: kotlin.Int
@kotlin.Deprecated(message = "Use 'step' property instead.", replaceWith = kotlin.ReplaceWith(expression = "step", imports = {})) public open override /*1*/ val increment: kotlin.Int
public open override /*1*/ fun <get-increment>(): kotlin.Int
public final val last: kotlin.Char
public final fun <get-last>(): kotlin.Char
@kotlin.Deprecated(message = "Use first instead.", replaceWith = kotlin.ReplaceWith(expression = "first", imports = {})) public open override /*1*/ val start: kotlin.Char
@kotlin.Deprecated(message = "Use 'first' property instead.", replaceWith = kotlin.ReplaceWith(expression = "first", imports = {})) public open override /*1*/ val start: kotlin.Char
public open override /*1*/ fun <get-start>(): kotlin.Char
public final val step: kotlin.Int
public final fun <get-step>(): kotlin.Int
public open fun isEmpty(): kotlin.Boolean
public open override /*1*/ fun iterator(): kotlin.CharIterator
@@ -252,17 +258,17 @@ public open class CharProgression : kotlin.Progression<kotlin.Char> {
}
internal final class CharProgressionIterator : kotlin.CharIterator {
/*primary*/ public constructor CharProgressionIterator(/*0*/ first: kotlin.Char, /*1*/ last: kotlin.Char, /*2*/ increment: kotlin.Int)
/*primary*/ public constructor CharProgressionIterator(/*0*/ first: kotlin.Char, /*1*/ last: kotlin.Char, /*2*/ step: kotlin.Int)
private final val finalElement: kotlin.Int
private final fun <get-finalElement>(): kotlin.Int
private final var hasNext: kotlin.Boolean
private final fun <get-hasNext>(): kotlin.Boolean
private final fun <set-hasNext>(/*0*/ <set-?>: kotlin.Boolean): kotlin.Unit
public final val increment: kotlin.Int
public final fun <get-increment>(): kotlin.Int
private final var next: kotlin.Int
private final fun <get-next>(): kotlin.Int
private final fun <set-next>(/*0*/ <set-?>: kotlin.Int): kotlin.Unit
public final val step: kotlin.Int
public final fun <get-step>(): kotlin.Int
public open override /*1*/ fun hasNext(): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun next(): kotlin.Char
public open override /*1*/ fun nextChar(): kotlin.Char
@@ -276,12 +282,14 @@ public final class CharRange : kotlin.CharProgression, kotlin.ClosedRange<kotlin
public open override /*1*/ fun <get-endInclusive>(): kotlin.Char
public final override /*1*/ /*fake_override*/ val first: kotlin.Char
public final override /*1*/ /*fake_override*/ fun <get-first>(): kotlin.Char
public open override /*1*/ /*fake_override*/ val increment: kotlin.Int
@kotlin.Deprecated(message = "Use 'step' property instead.", replaceWith = kotlin.ReplaceWith(expression = "step", imports = {})) public open override /*1*/ /*fake_override*/ val increment: kotlin.Int
public open override /*1*/ /*fake_override*/ fun <get-increment>(): kotlin.Int
public final override /*1*/ /*fake_override*/ val last: kotlin.Char
public final override /*1*/ /*fake_override*/ fun <get-last>(): kotlin.Char
public open override /*2*/ val start: kotlin.Char
public open override /*2*/ fun <get-start>(): kotlin.Char
public final override /*1*/ /*fake_override*/ val step: kotlin.Int
public final override /*1*/ /*fake_override*/ fun <get-step>(): kotlin.Int
public open override /*1*/ fun contains(/*0*/ value: kotlin.Char): kotlin.Boolean
public open override /*2*/ fun isEmpty(): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.CharIterator
@@ -654,17 +662,19 @@ public abstract class IntIterator : kotlin.Iterator<kotlin.Int> {
}
public open class IntProgression : kotlin.Progression<kotlin.Int> {
/*primary*/ @kotlin.Deprecated(message = "This constructor will become private soon. Use IntProgression.fromClosedRange() instead.", replaceWith = kotlin.ReplaceWith(expression = "IntProgression.fromClosedRange(start, endInclusive, increment)", imports = {})) public constructor IntProgression(/*0*/ start: kotlin.Int, /*1*/ endInclusive: kotlin.Int, /*2*/ increment: kotlin.Int)
/*primary*/ @kotlin.Deprecated(message = "This constructor will become private soon. Use IntProgression.fromClosedRange() instead.", replaceWith = kotlin.ReplaceWith(expression = "IntProgression.fromClosedRange(start, endInclusive, step)", imports = {})) public constructor IntProgression(/*0*/ start: kotlin.Int, /*1*/ endInclusive: kotlin.Int, /*2*/ step: kotlin.Int)
@kotlin.Deprecated(message = "Use 'last' property instead.") public open override /*1*/ val end: kotlin.Int
public open override /*1*/ fun <get-end>(): kotlin.Int
public final val first: kotlin.Int
public final fun <get-first>(): kotlin.Int
public open override /*1*/ val increment: kotlin.Int
@kotlin.Deprecated(message = "Use 'step' property instead.", replaceWith = kotlin.ReplaceWith(expression = "step", imports = {})) public open override /*1*/ val increment: kotlin.Int
public open override /*1*/ fun <get-increment>(): kotlin.Int
public final val last: kotlin.Int
public final fun <get-last>(): kotlin.Int
@kotlin.Deprecated(message = "Use first instead.", replaceWith = kotlin.ReplaceWith(expression = "first", imports = {})) public open override /*1*/ val start: kotlin.Int
@kotlin.Deprecated(message = "Use 'first' property instead.", replaceWith = kotlin.ReplaceWith(expression = "first", imports = {})) public open override /*1*/ val start: kotlin.Int
public open override /*1*/ fun <get-start>(): kotlin.Int
public final val step: kotlin.Int
public final fun <get-step>(): kotlin.Int
public open fun isEmpty(): kotlin.Boolean
public open override /*1*/ fun iterator(): kotlin.IntIterator
@@ -675,17 +685,17 @@ public open class IntProgression : kotlin.Progression<kotlin.Int> {
}
internal final class IntProgressionIterator : kotlin.IntIterator {
/*primary*/ public constructor IntProgressionIterator(/*0*/ first: kotlin.Int, /*1*/ last: kotlin.Int, /*2*/ increment: kotlin.Int)
/*primary*/ public constructor IntProgressionIterator(/*0*/ first: kotlin.Int, /*1*/ last: kotlin.Int, /*2*/ step: kotlin.Int)
private final val finalElement: kotlin.Int
private final fun <get-finalElement>(): kotlin.Int
private final var hasNext: kotlin.Boolean
private final fun <get-hasNext>(): kotlin.Boolean
private final fun <set-hasNext>(/*0*/ <set-?>: kotlin.Boolean): kotlin.Unit
public final val increment: kotlin.Int
public final fun <get-increment>(): kotlin.Int
private final var next: kotlin.Int
private final fun <get-next>(): kotlin.Int
private final fun <set-next>(/*0*/ <set-?>: kotlin.Int): kotlin.Unit
public final val step: kotlin.Int
public final fun <get-step>(): kotlin.Int
public open override /*1*/ fun hasNext(): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun next(): kotlin.Int
public open override /*1*/ fun nextInt(): kotlin.Int
@@ -699,12 +709,14 @@ public final class IntRange : kotlin.IntProgression, kotlin.ClosedRange<kotlin.I
public open override /*1*/ fun <get-endInclusive>(): kotlin.Int
public final override /*1*/ /*fake_override*/ val first: kotlin.Int
public final override /*1*/ /*fake_override*/ fun <get-first>(): kotlin.Int
public open override /*1*/ /*fake_override*/ val increment: kotlin.Int
@kotlin.Deprecated(message = "Use 'step' property instead.", replaceWith = kotlin.ReplaceWith(expression = "step", imports = {})) public open override /*1*/ /*fake_override*/ val increment: kotlin.Int
public open override /*1*/ /*fake_override*/ fun <get-increment>(): kotlin.Int
public final override /*1*/ /*fake_override*/ val last: kotlin.Int
public final override /*1*/ /*fake_override*/ fun <get-last>(): kotlin.Int
public open override /*2*/ val start: kotlin.Int
public open override /*2*/ fun <get-start>(): kotlin.Int
public final override /*1*/ /*fake_override*/ val step: kotlin.Int
public final override /*1*/ /*fake_override*/ fun <get-step>(): kotlin.Int
public open override /*1*/ fun contains(/*0*/ value: kotlin.Int): kotlin.Boolean
public open override /*2*/ fun isEmpty(): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.IntIterator
@@ -844,17 +856,19 @@ public abstract class LongIterator : kotlin.Iterator<kotlin.Long> {
}
public open class LongProgression : kotlin.Progression<kotlin.Long> {
/*primary*/ @kotlin.Deprecated(message = "This constructor will become private soon. Use LongProgression.fromClosedRange() instead.", replaceWith = kotlin.ReplaceWith(expression = "LongProgression.fromClosedRange(start, endInclusive, increment)", imports = {})) public constructor LongProgression(/*0*/ start: kotlin.Long, /*1*/ endInclusive: kotlin.Long, /*2*/ increment: kotlin.Long)
/*primary*/ @kotlin.Deprecated(message = "This constructor will become private soon. Use LongProgression.fromClosedRange() instead.", replaceWith = kotlin.ReplaceWith(expression = "LongProgression.fromClosedRange(start, endInclusive, step)", imports = {})) public constructor LongProgression(/*0*/ start: kotlin.Long, /*1*/ endInclusive: kotlin.Long, /*2*/ step: kotlin.Long)
@kotlin.Deprecated(message = "Use 'last' property instead.") public open override /*1*/ val end: kotlin.Long
public open override /*1*/ fun <get-end>(): kotlin.Long
public final val first: kotlin.Long
public final fun <get-first>(): kotlin.Long
public open override /*1*/ val increment: kotlin.Long
@kotlin.Deprecated(message = "Use 'step' property instead.", replaceWith = kotlin.ReplaceWith(expression = "step", imports = {})) public open override /*1*/ val increment: kotlin.Long
public open override /*1*/ fun <get-increment>(): kotlin.Long
public final val last: kotlin.Long
public final fun <get-last>(): kotlin.Long
@kotlin.Deprecated(message = "Use first instead.", replaceWith = kotlin.ReplaceWith(expression = "first", imports = {})) public open override /*1*/ val start: kotlin.Long
@kotlin.Deprecated(message = "Use 'first' property instead.", replaceWith = kotlin.ReplaceWith(expression = "first", imports = {})) public open override /*1*/ val start: kotlin.Long
public open override /*1*/ fun <get-start>(): kotlin.Long
public final val step: kotlin.Long
public final fun <get-step>(): kotlin.Long
public open fun isEmpty(): kotlin.Boolean
public open override /*1*/ fun iterator(): kotlin.LongIterator
@@ -865,17 +879,17 @@ public open class LongProgression : kotlin.Progression<kotlin.Long> {
}
internal final class LongProgressionIterator : kotlin.LongIterator {
/*primary*/ public constructor LongProgressionIterator(/*0*/ first: kotlin.Long, /*1*/ last: kotlin.Long, /*2*/ increment: kotlin.Long)
/*primary*/ public constructor LongProgressionIterator(/*0*/ first: kotlin.Long, /*1*/ last: kotlin.Long, /*2*/ step: kotlin.Long)
private final val finalElement: kotlin.Long
private final fun <get-finalElement>(): kotlin.Long
private final var hasNext: kotlin.Boolean
private final fun <get-hasNext>(): kotlin.Boolean
private final fun <set-hasNext>(/*0*/ <set-?>: kotlin.Boolean): kotlin.Unit
public final val increment: kotlin.Long
public final fun <get-increment>(): kotlin.Long
private final var next: kotlin.Long
private final fun <get-next>(): kotlin.Long
private final fun <set-next>(/*0*/ <set-?>: kotlin.Long): kotlin.Unit
public final val step: kotlin.Long
public final fun <get-step>(): kotlin.Long
public open override /*1*/ fun hasNext(): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun next(): kotlin.Long
public open override /*1*/ fun nextLong(): kotlin.Long
@@ -889,12 +903,14 @@ public final class LongRange : kotlin.LongProgression, kotlin.ClosedRange<kotlin
public open override /*1*/ fun <get-endInclusive>(): kotlin.Long
public final override /*1*/ /*fake_override*/ val first: kotlin.Long
public final override /*1*/ /*fake_override*/ fun <get-first>(): kotlin.Long
public open override /*1*/ /*fake_override*/ val increment: kotlin.Long
@kotlin.Deprecated(message = "Use 'step' property instead.", replaceWith = kotlin.ReplaceWith(expression = "step", imports = {})) public open override /*1*/ /*fake_override*/ val increment: kotlin.Long
public open override /*1*/ /*fake_override*/ fun <get-increment>(): kotlin.Long
public final override /*1*/ /*fake_override*/ val last: kotlin.Long
public final override /*1*/ /*fake_override*/ fun <get-last>(): kotlin.Long
public open override /*2*/ val start: kotlin.Long
public open override /*2*/ fun <get-start>(): kotlin.Long
public final override /*1*/ /*fake_override*/ val step: kotlin.Long
public final override /*1*/ /*fake_override*/ fun <get-step>(): kotlin.Long
public open override /*1*/ fun contains(/*0*/ value: kotlin.Long): kotlin.Boolean
public open override /*2*/ fun isEmpty(): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.LongIterator
@@ -1169,17 +1185,19 @@ public abstract class ShortIterator : kotlin.Iterator<kotlin.Short> {
}
@kotlin.Deprecated(level = DeprecationLevel.WARNING, message = "Use IntProgression instead.", replaceWith = kotlin.ReplaceWith(expression = "IntProgression", imports = {})) public open class ShortProgression : kotlin.Progression<kotlin.Short> {
/*primary*/ @kotlin.Deprecated(message = "This constructor will become private soon. Use ShortProgression.fromClosedRange() instead.", replaceWith = kotlin.ReplaceWith(expression = "ShortProgression.fromClosedRange(start, endInclusive, increment)", imports = {})) public constructor ShortProgression(/*0*/ start: kotlin.Short, /*1*/ endInclusive: kotlin.Short, /*2*/ increment: kotlin.Int)
/*primary*/ @kotlin.Deprecated(message = "This constructor will become private soon. Use ShortProgression.fromClosedRange() instead.", replaceWith = kotlin.ReplaceWith(expression = "ShortProgression.fromClosedRange(start, endInclusive, step)", imports = {})) public constructor ShortProgression(/*0*/ start: kotlin.Short, /*1*/ endInclusive: kotlin.Short, /*2*/ step: kotlin.Int)
@kotlin.Deprecated(message = "Use 'last' property instead.") public open override /*1*/ val end: kotlin.Short
public open override /*1*/ fun <get-end>(): kotlin.Short
public final val first: kotlin.Short
public final fun <get-first>(): kotlin.Short
public open override /*1*/ val increment: kotlin.Int
@kotlin.Deprecated(message = "Use 'step' property instead.", replaceWith = kotlin.ReplaceWith(expression = "step", imports = {})) public open override /*1*/ val increment: kotlin.Int
public open override /*1*/ fun <get-increment>(): kotlin.Int
public final val last: kotlin.Short
public final fun <get-last>(): kotlin.Short
@kotlin.Deprecated(message = "Use first instead.", replaceWith = kotlin.ReplaceWith(expression = "first", imports = {})) public open override /*1*/ val start: kotlin.Short
@kotlin.Deprecated(message = "Use 'first' property instead.", replaceWith = kotlin.ReplaceWith(expression = "first", imports = {})) public open override /*1*/ val start: kotlin.Short
public open override /*1*/ fun <get-start>(): kotlin.Short
public final val step: kotlin.Int
public final fun <get-step>(): kotlin.Int
public open fun isEmpty(): kotlin.Boolean
public open override /*1*/ fun iterator(): kotlin.ShortIterator
@@ -1190,17 +1208,17 @@ public abstract class ShortIterator : kotlin.Iterator<kotlin.Short> {
}
internal final class ShortProgressionIterator : kotlin.ShortIterator {
/*primary*/ public constructor ShortProgressionIterator(/*0*/ first: kotlin.Short, /*1*/ last: kotlin.Short, /*2*/ increment: kotlin.Int)
/*primary*/ public constructor ShortProgressionIterator(/*0*/ first: kotlin.Short, /*1*/ last: kotlin.Short, /*2*/ step: kotlin.Int)
private final val finalElement: kotlin.Int
private final fun <get-finalElement>(): kotlin.Int
private final var hasNext: kotlin.Boolean
private final fun <get-hasNext>(): kotlin.Boolean
private final fun <set-hasNext>(/*0*/ <set-?>: kotlin.Boolean): kotlin.Unit
public final val increment: kotlin.Int
public final fun <get-increment>(): kotlin.Int
private final var next: kotlin.Int
private final fun <get-next>(): kotlin.Int
private final fun <set-next>(/*0*/ <set-?>: kotlin.Int): kotlin.Unit
public final val step: kotlin.Int
public final fun <get-step>(): kotlin.Int
public open override /*1*/ fun hasNext(): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun next(): kotlin.Short
public open override /*1*/ fun nextShort(): kotlin.Short
@@ -1214,12 +1232,14 @@ internal final class ShortProgressionIterator : kotlin.ShortIterator {
public open override /*1*/ fun <get-endInclusive>(): kotlin.Short
public final override /*1*/ /*fake_override*/ val first: kotlin.Short
public final override /*1*/ /*fake_override*/ fun <get-first>(): kotlin.Short
public open override /*1*/ /*fake_override*/ val increment: kotlin.Int
@kotlin.Deprecated(message = "Use 'step' property instead.", replaceWith = kotlin.ReplaceWith(expression = "step", imports = {})) public open override /*1*/ /*fake_override*/ val increment: kotlin.Int
public open override /*1*/ /*fake_override*/ fun <get-increment>(): kotlin.Int
public final override /*1*/ /*fake_override*/ val last: kotlin.Short
public final override /*1*/ /*fake_override*/ fun <get-last>(): kotlin.Short
public open override /*2*/ val start: kotlin.Short
public open override /*2*/ fun <get-start>(): kotlin.Short
public final override /*1*/ /*fake_override*/ val step: kotlin.Int
public final override /*1*/ /*fake_override*/ fun <get-step>(): kotlin.Int
public open override /*1*/ fun contains(/*0*/ value: kotlin.Short): kotlin.Boolean
public open override /*2*/ fun isEmpty(): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.ShortIterator
@@ -20,12 +20,12 @@ package kotlin
/**
* An iterator over a progression of values of type `Byte`.
* @property increment the number by which the value is incremented on each step.
* @property step the number by which the value is incremented on each step.
*/
internal class ByteProgressionIterator(first: Byte, last: Byte, val increment: Int) : ByteIterator() {
internal class ByteProgressionIterator(first: Byte, last: Byte, val step: Int) : ByteIterator() {
private var next = first.toInt()
private val finalElement = last.toInt()
private var hasNext: Boolean = if (increment > 0) first <= last else first >= last
private var hasNext: Boolean = if (step > 0) first <= last else first >= last
override fun hasNext(): Boolean = hasNext
@@ -35,7 +35,7 @@ internal class ByteProgressionIterator(first: Byte, last: Byte, val increment: I
hasNext = false
}
else {
next += increment
next += step
}
return value.toByte()
}
@@ -43,12 +43,12 @@ internal class ByteProgressionIterator(first: Byte, last: Byte, val increment: I
/**
* An iterator over a progression of values of type `Char`.
* @property increment the number by which the value is incremented on each step.
* @property step the number by which the value is incremented on each step.
*/
internal class CharProgressionIterator(first: Char, last: Char, val increment: Int) : CharIterator() {
internal class CharProgressionIterator(first: Char, last: Char, val step: Int) : CharIterator() {
private var next = first.toInt()
private val finalElement = last.toInt()
private var hasNext: Boolean = if (increment > 0) first <= last else first >= last
private var hasNext: Boolean = if (step > 0) first <= last else first >= last
override fun hasNext(): Boolean = hasNext
@@ -58,7 +58,7 @@ internal class CharProgressionIterator(first: Char, last: Char, val increment: I
hasNext = false
}
else {
next += increment
next += step
}
return value.toChar()
}
@@ -66,12 +66,12 @@ internal class CharProgressionIterator(first: Char, last: Char, val increment: I
/**
* An iterator over a progression of values of type `Short`.
* @property increment the number by which the value is incremented on each step.
* @property step the number by which the value is incremented on each step.
*/
internal class ShortProgressionIterator(first: Short, last: Short, val increment: Int) : ShortIterator() {
internal class ShortProgressionIterator(first: Short, last: Short, val step: Int) : ShortIterator() {
private var next = first.toInt()
private val finalElement = last.toInt()
private var hasNext: Boolean = if (increment > 0) first <= last else first >= last
private var hasNext: Boolean = if (step > 0) first <= last else first >= last
override fun hasNext(): Boolean = hasNext
@@ -81,7 +81,7 @@ internal class ShortProgressionIterator(first: Short, last: Short, val increment
hasNext = false
}
else {
next += increment
next += step
}
return value.toShort()
}
@@ -89,12 +89,12 @@ internal class ShortProgressionIterator(first: Short, last: Short, val increment
/**
* An iterator over a progression of values of type `Int`.
* @property increment the number by which the value is incremented on each step.
* @property step the number by which the value is incremented on each step.
*/
internal class IntProgressionIterator(first: Int, last: Int, val increment: Int) : IntIterator() {
internal class IntProgressionIterator(first: Int, last: Int, val step: Int) : IntIterator() {
private var next = first
private val finalElement = last
private var hasNext: Boolean = if (increment > 0) first <= last else first >= last
private var hasNext: Boolean = if (step > 0) first <= last else first >= last
override fun hasNext(): Boolean = hasNext
@@ -104,7 +104,7 @@ internal class IntProgressionIterator(first: Int, last: Int, val increment: Int)
hasNext = false
}
else {
next += increment
next += step
}
return value
}
@@ -112,12 +112,12 @@ internal class IntProgressionIterator(first: Int, last: Int, val increment: Int)
/**
* An iterator over a progression of values of type `Long`.
* @property increment the number by which the value is incremented on each step.
* @property step the number by which the value is incremented on each step.
*/
internal class LongProgressionIterator(first: Long, last: Long, val increment: Long) : LongIterator() {
internal class LongProgressionIterator(first: Long, last: Long, val step: Long) : LongIterator() {
private var next = first
private val finalElement = last
private var hasNext: Boolean = if (increment > 0) first <= last else first >= last
private var hasNext: Boolean = if (step > 0) first <= last else first >= last
override fun hasNext(): Boolean = hasNext
@@ -127,7 +127,7 @@ internal class LongProgressionIterator(first: Long, last: Long, val increment: L
hasNext = false
}
else {
next += increment
next += step
}
return value
}
+100 -50
View File
@@ -25,27 +25,33 @@ import kotlin.internal.getProgressionLastElement
* A progression of values of type `Byte`.
*/
public open class ByteProgression
@Deprecated("This constructor will become private soon. Use ByteProgression.fromClosedRange() instead.", ReplaceWith("ByteProgression.fromClosedRange(start, endInclusive, increment)"))
@Deprecated("This constructor will become private soon. Use ByteProgression.fromClosedRange() instead.", ReplaceWith("ByteProgression.fromClosedRange(start, endInclusive, step)"))
public constructor
(
start: Byte,
endInclusive: Byte,
override val increment: Int
step: Int
) : Progression<Byte> /*, Iterable<Byte> */ {
init {
if (increment == 0) throw IllegalArgumentException("Increment must be non-zero")
if (step == 0) throw IllegalArgumentException("Step must be non-zero")
}
/**
* The first element in the progression.
*/
public val first: Byte = start
/**
* The last element in the progression.
*/
public val last: Byte = getProgressionLastElement(start.toInt(), endInclusive.toInt(), increment).toByte()
public val last: Byte = getProgressionLastElement(start.toInt(), endInclusive.toInt(), step).toByte()
@Deprecated("Use first instead.", ReplaceWith("first"))
/**
* The step of the progression.
*/
public val step: Int = step
@Deprecated("Use 'first' property instead.", ReplaceWith("first"))
public override val start: Byte get() = first
/**
@@ -54,19 +60,23 @@ public open class ByteProgression
@Deprecated("Use 'last' property instead.")
public override val end: Byte = endInclusive
override fun iterator(): ByteIterator = ByteProgressionIterator(first, last, increment)
@Deprecated("Use 'step' property instead.", ReplaceWith("step"))
public override val increment: Int get() = step
override fun iterator(): ByteIterator = ByteProgressionIterator(first, last, step)
/** Checks if the progression is empty. */
public open fun isEmpty(): Boolean = if (increment > 0) first > last else first < last
public open fun isEmpty(): Boolean = if (step > 0) first > last else first < last
override fun equals(other: Any?): Boolean =
other is ByteProgression && (isEmpty() && other.isEmpty() ||
first == other.first && last == other.last && increment == other.increment)
first == other.first && last == other.last && step == other.step)
override fun hashCode(): Int =
if (isEmpty()) -1 else (31 * (31 * first.toInt() + last.toInt()) + increment)
if (isEmpty()) -1 else (31 * (31 * first.toInt() + last.toInt()) + step)
override fun toString(): String = if (increment > 0) "$first..$last step $increment" else "$first downTo $last step ${-increment}"
override fun toString(): String = if (step > 0) "$first..$last step $step" else "$first downTo $last step ${-step}"
companion object {
/**
@@ -83,27 +93,33 @@ public open class ByteProgression
* A progression of values of type `Char`.
*/
public open class CharProgression
@Deprecated("This constructor will become private soon. Use CharProgression.fromClosedRange() instead.", ReplaceWith("CharProgression.fromClosedRange(start, endInclusive, increment)"))
@Deprecated("This constructor will become private soon. Use CharProgression.fromClosedRange() instead.", ReplaceWith("CharProgression.fromClosedRange(start, endInclusive, step)"))
public constructor
(
start: Char,
endInclusive: Char,
override val increment: Int
step: Int
) : Progression<Char> /*, Iterable<Char> */ {
init {
if (increment == 0) throw IllegalArgumentException("Increment must be non-zero")
if (step == 0) throw IllegalArgumentException("Step must be non-zero")
}
/**
* The first element in the progression.
*/
public val first: Char = start
/**
* The last element in the progression.
*/
public val last: Char = getProgressionLastElement(start.toInt(), endInclusive.toInt(), increment).toChar()
public val last: Char = getProgressionLastElement(start.toInt(), endInclusive.toInt(), step).toChar()
@Deprecated("Use first instead.", ReplaceWith("first"))
/**
* The step of the progression.
*/
public val step: Int = step
@Deprecated("Use 'first' property instead.", ReplaceWith("first"))
public override val start: Char get() = first
/**
@@ -112,19 +128,23 @@ public open class CharProgression
@Deprecated("Use 'last' property instead.")
public override val end: Char = endInclusive
override fun iterator(): CharIterator = CharProgressionIterator(first, last, increment)
@Deprecated("Use 'step' property instead.", ReplaceWith("step"))
public override val increment: Int get() = step
override fun iterator(): CharIterator = CharProgressionIterator(first, last, step)
/** Checks if the progression is empty. */
public open fun isEmpty(): Boolean = if (increment > 0) first > last else first < last
public open fun isEmpty(): Boolean = if (step > 0) first > last else first < last
override fun equals(other: Any?): Boolean =
other is CharProgression && (isEmpty() && other.isEmpty() ||
first == other.first && last == other.last && increment == other.increment)
first == other.first && last == other.last && step == other.step)
override fun hashCode(): Int =
if (isEmpty()) -1 else (31 * (31 * first.toInt() + last.toInt()) + increment)
if (isEmpty()) -1 else (31 * (31 * first.toInt() + last.toInt()) + step)
override fun toString(): String = if (increment > 0) "$first..$last step $increment" else "$first downTo $last step ${-increment}"
override fun toString(): String = if (step > 0) "$first..$last step $step" else "$first downTo $last step ${-step}"
companion object {
/**
@@ -142,27 +162,33 @@ public open class CharProgression
* A progression of values of type `Short`.
*/
public open class ShortProgression
@Deprecated("This constructor will become private soon. Use ShortProgression.fromClosedRange() instead.", ReplaceWith("ShortProgression.fromClosedRange(start, endInclusive, increment)"))
@Deprecated("This constructor will become private soon. Use ShortProgression.fromClosedRange() instead.", ReplaceWith("ShortProgression.fromClosedRange(start, endInclusive, step)"))
public constructor
(
start: Short,
endInclusive: Short,
override val increment: Int
step: Int
) : Progression<Short> /*, Iterable<Short> */ {
init {
if (increment == 0) throw IllegalArgumentException("Increment must be non-zero")
if (step == 0) throw IllegalArgumentException("Step must be non-zero")
}
/**
* The first element in the progression.
*/
public val first: Short = start
/**
* The last element in the progression.
*/
public val last: Short = getProgressionLastElement(start.toInt(), endInclusive.toInt(), increment).toShort()
public val last: Short = getProgressionLastElement(start.toInt(), endInclusive.toInt(), step).toShort()
@Deprecated("Use first instead.", ReplaceWith("first"))
/**
* The step of the progression.
*/
public val step: Int = step
@Deprecated("Use 'first' property instead.", ReplaceWith("first"))
public override val start: Short get() = first
/**
@@ -171,19 +197,23 @@ public open class ShortProgression
@Deprecated("Use 'last' property instead.")
public override val end: Short = endInclusive
override fun iterator(): ShortIterator = ShortProgressionIterator(first, last, increment)
@Deprecated("Use 'step' property instead.", ReplaceWith("step"))
public override val increment: Int get() = step
override fun iterator(): ShortIterator = ShortProgressionIterator(first, last, step)
/** Checks if the progression is empty. */
public open fun isEmpty(): Boolean = if (increment > 0) first > last else first < last
public open fun isEmpty(): Boolean = if (step > 0) first > last else first < last
override fun equals(other: Any?): Boolean =
other is ShortProgression && (isEmpty() && other.isEmpty() ||
first == other.first && last == other.last && increment == other.increment)
first == other.first && last == other.last && step == other.step)
override fun hashCode(): Int =
if (isEmpty()) -1 else (31 * (31 * first.toInt() + last.toInt()) + increment)
if (isEmpty()) -1 else (31 * (31 * first.toInt() + last.toInt()) + step)
override fun toString(): String = if (increment > 0) "$first..$last step $increment" else "$first downTo $last step ${-increment}"
override fun toString(): String = if (step > 0) "$first..$last step $step" else "$first downTo $last step ${-step}"
companion object {
/**
@@ -200,27 +230,33 @@ public open class ShortProgression
* A progression of values of type `Int`.
*/
public open class IntProgression
@Deprecated("This constructor will become private soon. Use IntProgression.fromClosedRange() instead.", ReplaceWith("IntProgression.fromClosedRange(start, endInclusive, increment)"))
@Deprecated("This constructor will become private soon. Use IntProgression.fromClosedRange() instead.", ReplaceWith("IntProgression.fromClosedRange(start, endInclusive, step)"))
public constructor
(
start: Int,
endInclusive: Int,
override val increment: Int
step: Int
) : Progression<Int> /*, Iterable<Int> */ {
init {
if (increment == 0) throw IllegalArgumentException("Increment must be non-zero")
if (step == 0) throw IllegalArgumentException("Step must be non-zero")
}
/**
* The first element in the progression.
*/
public val first: Int = start
/**
* The last element in the progression.
*/
public val last: Int = getProgressionLastElement(start.toInt(), endInclusive.toInt(), increment).toInt()
public val last: Int = getProgressionLastElement(start.toInt(), endInclusive.toInt(), step).toInt()
@Deprecated("Use first instead.", ReplaceWith("first"))
/**
* The step of the progression.
*/
public val step: Int = step
@Deprecated("Use 'first' property instead.", ReplaceWith("first"))
public override val start: Int get() = first
/**
@@ -229,19 +265,23 @@ public open class IntProgression
@Deprecated("Use 'last' property instead.")
public override val end: Int = endInclusive
override fun iterator(): IntIterator = IntProgressionIterator(first, last, increment)
@Deprecated("Use 'step' property instead.", ReplaceWith("step"))
public override val increment: Int get() = step
override fun iterator(): IntIterator = IntProgressionIterator(first, last, step)
/** Checks if the progression is empty. */
public open fun isEmpty(): Boolean = if (increment > 0) first > last else first < last
public open fun isEmpty(): Boolean = if (step > 0) first > last else first < last
override fun equals(other: Any?): Boolean =
other is IntProgression && (isEmpty() && other.isEmpty() ||
first == other.first && last == other.last && increment == other.increment)
first == other.first && last == other.last && step == other.step)
override fun hashCode(): Int =
if (isEmpty()) -1 else (31 * (31 * first + last) + increment)
if (isEmpty()) -1 else (31 * (31 * first + last) + step)
override fun toString(): String = if (increment > 0) "$first..$last step $increment" else "$first downTo $last step ${-increment}"
override fun toString(): String = if (step > 0) "$first..$last step $step" else "$first downTo $last step ${-step}"
companion object {
/**
@@ -258,27 +298,33 @@ public open class IntProgression
* A progression of values of type `Long`.
*/
public open class LongProgression
@Deprecated("This constructor will become private soon. Use LongProgression.fromClosedRange() instead.", ReplaceWith("LongProgression.fromClosedRange(start, endInclusive, increment)"))
@Deprecated("This constructor will become private soon. Use LongProgression.fromClosedRange() instead.", ReplaceWith("LongProgression.fromClosedRange(start, endInclusive, step)"))
public constructor
(
start: Long,
endInclusive: Long,
override val increment: Long
step: Long
) : Progression<Long> /*, Iterable<Long> */ {
init {
if (increment == 0L) throw IllegalArgumentException("Increment must be non-zero")
if (step == 0L) throw IllegalArgumentException("Step must be non-zero")
}
/**
* The first element in the progression.
*/
public val first: Long = start
/**
* The last element in the progression.
*/
public val last: Long = getProgressionLastElement(start.toLong(), endInclusive.toLong(), increment).toLong()
public val last: Long = getProgressionLastElement(start.toLong(), endInclusive.toLong(), step).toLong()
@Deprecated("Use first instead.", ReplaceWith("first"))
/**
* The step of the progression.
*/
public val step: Long = step
@Deprecated("Use 'first' property instead.", ReplaceWith("first"))
public override val start: Long get() = first
/**
@@ -287,19 +333,23 @@ public open class LongProgression
@Deprecated("Use 'last' property instead.")
public override val end: Long = endInclusive
override fun iterator(): LongIterator = LongProgressionIterator(first, last, increment)
@Deprecated("Use 'step' property instead.", ReplaceWith("step"))
public override val increment: Long get() = step
override fun iterator(): LongIterator = LongProgressionIterator(first, last, step)
/** Checks if the progression is empty. */
public open fun isEmpty(): Boolean = if (increment > 0) first > last else first < last
public open fun isEmpty(): Boolean = if (step > 0) first > last else first < last
override fun equals(other: Any?): Boolean =
other is LongProgression && (isEmpty() && other.isEmpty() ||
first == other.first && last == other.last && increment == other.increment)
first == other.first && last == other.last && step == other.step)
override fun hashCode(): Int =
if (isEmpty()) -1 else (31 * (31 * (first xor (first ushr 32)) + (last xor (last ushr 32))) + (increment xor (increment ushr 32))).toInt()
if (isEmpty()) -1 else (31 * (31 * (first xor (first ushr 32)) + (last xor (last ushr 32))) + (step xor (step ushr 32))).toInt()
override fun toString(): String = if (increment > 0) "$first..$last step $increment" else "$first downTo $last step ${-increment}"
override fun toString(): String = if (step > 0) "$first..$last step $step" else "$first downTo $last step ${-step}"
companion object {
/**
@@ -42,26 +42,26 @@ public fun getProgressionFinalElement(start: Int, end: Int, increment: Int): Int
/**
* Calculates the final element of a bounded arithmetic progression, i.e. the last element of the progression which is in the range
* from [start] to [end] in case of a positive [increment], or from [end] to [start] in case of a negative
* increment.
* from [start] to [end] in case of a positive [step], or from [end] to [start] in case of a negative
* [step].
*
* No validation on passed parameters is performed. The given parameters should satisfy the condition: either
* `increment > 0` and `start >= end`, or `increment < 0` and`start >= end`.
* `step > 0` and `start >= end`, or `step < 0` and`start >= end`.
* @param start first element of the progression
* @param end ending bound for the progression
* @param increment increment, or difference of successive elements in the progression
* @param step increment, or difference of successive elements in the progression
* @return the final element of the progression
* @suppress
*/
internal fun getProgressionLastElement(start: Int, end: Int, increment: Int): Int {
if (increment > 0) {
return end - differenceModulo(end, start, increment)
internal fun getProgressionLastElement(start: Int, end: Int, step: Int): Int {
if (step > 0) {
return end - differenceModulo(end, start, step)
}
else if (increment < 0) {
return end + differenceModulo(start, end, -increment)
else if (step < 0) {
return end + differenceModulo(start, end, -step)
}
else {
throw IllegalArgumentException("Increment is zero.")
throw IllegalArgumentException("Step is zero.")
}
}
@@ -69,25 +69,25 @@ internal fun getProgressionLastElement(start: Int, end: Int, increment: Int): In
public fun getProgressionFinalElement(start: Long, end: Long, increment: Long): Long = getProgressionLastElement(start, end, increment)
/**
* Calculates the final element of a bounded arithmetic progression, i.e. the last element of the progression which is in the range
* from [start] to [end] in case of a positive [increment], or from [end] to [start] in case of a negative
* increment.
* from [start] to [end] in case of a positive [step], or from [end] to [start] in case of a negative
* [step].
*
* No validation on passed parameters is performed. The given parameters should satisfy the condition: either
* `increment > 0` and `start >= end`, or `increment < 0` and`start >= end`.
* `step > 0` and `start >= end`, or `step < 0` and`start >= end`.
* @param start first element of the progression
* @param end ending bound for the progression
* @param increment increment, or difference of successive elements in the progression
* @param step increment, or difference of successive elements in the progression
* @return the final element of the progression
* @suppress
*/
internal fun getProgressionLastElement(start: Long, end: Long, increment: Long): Long {
if (increment > 0) {
return end - differenceModulo(end, start, increment)
internal fun getProgressionLastElement(start: Long, end: Long, step: Long): Long {
if (step > 0) {
return end - differenceModulo(end, start, step)
}
else if (increment < 0) {
return end + differenceModulo(start, end, -increment)
else if (step < 0) {
return end + differenceModulo(start, end, -step)
}
else {
throw IllegalArgumentException("Increment is zero.")
throw IllegalArgumentException("Step is zero.")
}
}
@@ -33,12 +33,12 @@ fun integerProgressionIterator(kind: ProgressionKind): String {
return """/**
* An iterator over a progression of values of type `$t`.
* @property increment the number by which the value is incremented on each step.
* @property step the number by which the value is incremented on each step.
*/
internal class ${t}ProgressionIterator(first: $t, last: $t, val increment: $incrementType) : ${t}Iterator() {
internal class ${t}ProgressionIterator(first: $t, last: $t, val step: $incrementType) : ${t}Iterator() {
private var next = first$toInt
private val finalElement = last$toInt
private var hasNext: Boolean = if (increment > 0) first <= last else first >= last
private var hasNext: Boolean = if (step > 0) first <= last else first >= last
override fun hasNext(): Boolean = hasNext
@@ -48,7 +48,7 @@ internal class ${t}ProgressionIterator(first: $t, last: $t, val increment: $incr
hasNext = false
}
else {
next += increment
next += step
}
return value$toType
}
@@ -36,15 +36,15 @@ class GenerateProgressions(out: PrintWriter) : BuiltInsSourceGenerator(out) {
LONG -> "0L"
else -> "0"
}
val checkZero = "if (increment == $zero) throw IllegalArgumentException(\"Increment must be non-zero\")"
val checkZero = "if (step == $zero) throw IllegalArgumentException(\"Step must be non-zero\")"
val hashCode = "=\n" + when (kind) {
BYTE, CHAR, SHORT ->
" if (isEmpty()) -1 else (31 * (31 * first.toInt() + last.toInt()) + increment)"
" if (isEmpty()) -1 else (31 * (31 * first.toInt() + last.toInt()) + step)"
INT ->
" if (isEmpty()) -1 else (31 * (31 * first + last) + increment)"
" if (isEmpty()) -1 else (31 * (31 * first + last) + step)"
LONG ->
" if (isEmpty()) -1 else (31 * (31 * ${hashLong("first")} + ${hashLong("last")}) + ${hashLong("increment")}).toInt()"
" if (isEmpty()) -1 else (31 * (31 * ${hashLong("first")} + ${hashLong("last")}) + ${hashLong("step")}).toInt()"
else -> throw IllegalArgumentException()
}
@@ -56,12 +56,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, increment)"))
@Deprecated("This constructor will become private soon. Use $progression.fromClosedRange() instead.", ReplaceWith("$progression.fromClosedRange(start, endInclusive, step)"))
public constructor
(
start: $t,
endInclusive: $t,
override val increment: $incrementType
step: $incrementType
) : Progression<$t> /*, Iterable<$t> */ {
init {
$checkZero
@@ -71,12 +71,18 @@ public open class $progression
* The first element in the progression.
*/
public val first: $t = start
/**
* The last element in the progression.
*/
public val last: $t = getProgressionLastElement(start.to$incrementType(), endInclusive.to$incrementType(), increment).to$t()
public val last: $t = getProgressionLastElement(start.to$incrementType(), endInclusive.to$incrementType(), step).to$t()
@Deprecated("Use first instead.", ReplaceWith("first"))
/**
* The step of the progression.
*/
public val step: $incrementType = step
@Deprecated("Use 'first' property instead.", ReplaceWith("first"))
public override val start: $t get() = first
/**
@@ -85,18 +91,22 @@ public open class $progression
@Deprecated("Use 'last' property instead.")
public override val end: $t = endInclusive
override fun iterator(): ${t}Iterator = ${t}ProgressionIterator(first, last, increment)
@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. */
public open fun isEmpty(): Boolean = if (increment > 0) first > last else first < last
public open fun isEmpty(): Boolean = if (step > 0) first > last else first < last
override fun equals(other: Any?): Boolean =
other is $progression && (isEmpty() && other.isEmpty() ||
${compare("first")} && ${compare("last")} && ${compare("increment")})
${compare("first")} && ${compare("last")} && ${compare("step")})
override fun hashCode(): Int $hashCode
override fun toString(): String = ${"if (increment > 0) \"\$first..\$last step \$increment\" else \"\$first downTo \$last step \${-increment}\""}
override fun toString(): String = ${"if (step > 0) \"\$first..\$last step \$step\" else \"\$first downTo \$last step \${-step}\""}
companion object {
/**
+53 -50
View File
@@ -771,19 +771,19 @@
function () {
return [Kotlin.modules['builtins'].kotlin.Iterator];
},
function (start, end, increment) {
function (start, end, step) {
this.start = start;
this.end = end;
this.increment = increment;
this.step = step;
this.i = start;
}, {
next: function () {
var value = this.i;
this.i = this.i + this.increment;
this.i = this.i + this.step;
return value;
},
hasNext: function () {
if (this.increment > 0)
if (this.step > 0)
return this.i <= this.end;
else
return this.i >= this.end;
@@ -794,7 +794,7 @@
var classObject = this.constructor;
if (this instanceof classObject && other instanceof classObject) {
return this.isEmpty() && other.isEmpty() ||
(this.first === other.first && this.last === other.last && this.increment === other.increment);
(this.first === other.first && this.last === other.last && this.step === other.step);
}
return false;
}
@@ -803,13 +803,13 @@
var classObject = this.constructor;
if (this instanceof classObject && other instanceof classObject) {
return this.isEmpty() && other.isEmpty() ||
(this.first.equals_za3rmp$(other.first) && this.last.equals_za3rmp$(other.last) && this.increment.equals_za3rmp$(other.increment));
(this.first.equals_za3rmp$(other.first) && this.last.equals_za3rmp$(other.last) && this.step.equals_za3rmp$(other.step));
}
return false;
}
// reference implementation in core/builtins/src/kotlin/internal/progressionUtil.kt
function getProgressionFinalElement(start, end, increment) {
function getProgressionFinalElement(start, end, step) {
function mod(a, b) {
var mod = a % b;
return mod >= 0 ? mod : mod + b;
@@ -818,19 +818,19 @@
return mod(mod(a, c) - mod(b, c), c);
}
if (increment > 0) {
return end - differenceModulo(end, start, increment);
if (step > 0) {
return end - differenceModulo(end, start, step);
}
else if (increment < 0) {
return end + differenceModulo(start, end, -increment);
else if (step < 0) {
return end + differenceModulo(start, end, -step);
}
else {
throw new Kotlin.IllegalArgumentException('Increment is zero.');
throw new Kotlin.IllegalArgumentException('Step is zero.');
}
}
// reference implementation in core/builtins/src/kotlin/internal/progressionUtil.kt
function getProgressionFinalElementLong(start, end, increment) {
function getProgressionFinalElementLong(start, end, step) {
function mod(a, b) {
var mod = a.modulo(b);
return !mod.isNegative() ? mod : mod.add(b);
@@ -840,16 +840,16 @@
}
var diff;
if (increment.compareTo_za3rmp$(Kotlin.Long.ZERO) > 0) {
diff = differenceModulo(end, start, increment);
if (step.compareTo_za3rmp$(Kotlin.Long.ZERO) > 0) {
diff = differenceModulo(end, start, step);
return diff.isZero() ? end : end.subtract(diff);
}
else if (increment.compareTo_za3rmp$(Kotlin.Long.ZERO) < 0) {
diff = differenceModulo(start, end, increment.unaryMinus());
else if (step.compareTo_za3rmp$(Kotlin.Long.ZERO) < 0) {
diff = differenceModulo(start, end, step.unaryMinus());
return diff.isZero() ? end : end.add(diff);
}
else {
throw new Kotlin.IllegalArgumentException('Increment is zero.');
throw new Kotlin.IllegalArgumentException('Step is zero.');
}
}
@@ -857,30 +857,31 @@
function () {
return [Kotlin.modules['builtins'].kotlin.Iterable];
},
function (start, end, increment) {
function (start, end, step) {
this.start = start;
this.endInclusive = end;
this.first = start;
this.last = getProgressionFinalElement(start, end, increment);
this.increment = increment;
if (this.increment === 0)
throw new Kotlin.IllegalArgumentException('Increment must be non-zero');
this.last = getProgressionFinalElement(start, end, step);
this.step = step;
this.increment = step;
if (this.step === 0)
throw new Kotlin.IllegalArgumentException('Step must be non-zero');
}, {
end: { get: function () {
return this.endInclusive;
}},
iterator: function () {
return new Kotlin.RangeIterator(this.first, this.last, this.increment);
return new Kotlin.RangeIterator(this.first, this.last, this.step);
},
isEmpty: function () {
return this.increment > 0 ? this.first > this.last : this.first < this.last;
return this.step > 0 ? this.first > this.last : this.first < this.last;
},
hashCode: function () {
return this.isEmpty() ? -1 : 31 * (31 * this.first + this.last) + this.increment;
return this.isEmpty() ? -1 : 31 * (31 * this.first + this.last) + this.step;
},
equals_za3rmp$: isSameNotNullRanges,
toString: function () {
return this.increment > 0 ? this.first.toString() + '..' + this.last + ' step ' + this.increment : this.first.toString() + ' downTo ' + this.last + ' step ' + -this.increment;
return this.step > 0 ? this.first.toString() + '..' + this.last + ' step ' + this.step : this.first.toString() + ' downTo ' + this.last + ' step ' + -this.step;
}
});
@@ -921,19 +922,19 @@
function () {
return [Kotlin.modules['builtins'].kotlin.Iterator];
},
function (start, end, increment) {
function (start, end, step) {
this.start = start;
this.end = end;
this.increment = increment;
this.step = step;
this.i = start;
}, {
next: function () {
var value = this.i;
this.i = this.i.add(this.increment);
this.i = this.i.add(this.step);
return value;
},
hasNext: function () {
if (this.increment.isNegative())
if (this.step.isNegative())
return this.i.compare(this.end) >= 0;
else
return this.i.compare(this.end) <= 0;
@@ -944,30 +945,31 @@
function () {
return [Kotlin.modules['builtins'].kotlin.Iterable];
},
function (start, end, increment) {
function (start, end, step) {
this.start = start;
this.endInclusive = end;
this.first = start;
this.last = getProgressionFinalElementLong(start, end, increment);
this.increment = increment;
if (this.increment.isZero())
throw new Kotlin.IllegalArgumentException('Increment must be non-zero');
this.last = getProgressionFinalElementLong(start, end, step);
this.step = step;
this.increment = step;
if (this.step.isZero())
throw new Kotlin.IllegalArgumentException('Step must be non-zero');
}, {
end: { get: function () {
return this.endInclusive;
}},
iterator: function () {
return new Kotlin.LongRangeIterator(this.first, this.last, this.increment);
return new Kotlin.LongRangeIterator(this.first, this.last, this.step);
},
isEmpty: function() {
return this.increment.isNegative() ? this.first.compare(this.last) < 0 : this.first.compare(this.last) > 0;
return this.step.isNegative() ? this.first.compare(this.last) < 0 : this.first.compare(this.last) > 0;
},
hashCode: function() {
return this.isEmpty() ? -1 : (31 * (31 * this.first.toInt() + this.last.toInt()) + this.increment.toInt());
return this.isEmpty() ? -1 : (31 * (31 * this.first.toInt() + this.last.toInt()) + this.step.toInt());
},
equals_za3rmp$: isSameLongRanges,
toString: function () {
return !this.increment.isNegative() ? this.first.toString() + '..' + this.last + ' step ' + this.increment : this.first.toString() + ' downTo ' + this.last + ' step ' + this.increment.unaryMinus();
return !this.step.isNegative() ? this.first.toString() + '..' + this.last + ' step ' + this.step : this.first.toString() + ' downTo ' + this.last + ' step ' + this.step.unaryMinus();
}
});
@@ -1008,12 +1010,12 @@
function () {
return [Kotlin.RangeIterator];
},
function (start, end, increment) {
Kotlin.RangeIterator.call(this, start, end, increment);
function (start, end, step) {
Kotlin.RangeIterator.call(this, start, end, step);
}, {
next: function () {
var value = this.i;
this.i = this.i + this.increment;
this.i = this.i + this.step;
return String.fromCharCode(value);
}
});
@@ -1022,14 +1024,15 @@
function () {
return [Kotlin.modules['builtins'].kotlin.Iterable];
},
function (start, end, increment) {
function (start, end, step) {
this.start = start;
this.endInclusive = end;
this.first = start;
this.startCode = start.charCodeAt(0);
this.endCode = getProgressionFinalElement(this.startCode, end.charCodeAt(0), increment);
this.endCode = getProgressionFinalElement(this.startCode, end.charCodeAt(0), step);
this.last = String.fromCharCode(this.endCode);
this.increment = increment;
this.step = step;
this.increment = step;
if (this.increment === 0)
throw new Kotlin.IllegalArgumentException('Increment must be non-zero');
}, {
@@ -1037,17 +1040,17 @@
return this.endInclusive;
}},
iterator: function () {
return new Kotlin.CharRangeIterator(this.startCode, this.endCode, this.increment);
return new Kotlin.CharRangeIterator(this.startCode, this.endCode, this.step);
},
isEmpty: function() {
return this.increment > 0 ? this.startCode > this.endCode : this.startCode < this.endCode;
return this.step > 0 ? this.startCode > this.endCode : this.startCode < this.endCode;
},
hashCode: function() {
return this.isEmpty() ? -1 : (31 * (31 * this.startCode|0 + this.endCode|0) + this.increment|0);
return this.isEmpty() ? -1 : (31 * (31 * this.startCode|0 + this.endCode|0) + this.step|0);
},
equals_za3rmp$: isSameNotNullRanges,
toString: function () {
return this.increment > 0 ? this.first.toString() + '..' + this.last + ' step ' + this.increment : this.first.toString() + ' downTo ' + this.last + ' step ' + -this.increment;
return this.step > 0 ? this.first.toString() + '..' + this.last + ' step ' + this.step : this.first.toString() + ' downTo ' + this.last + ' step ' + -this.step;
}
});
+27 -27
View File
@@ -577,7 +577,7 @@ public operator fun ClosedRange<Float>.contains(item: Short): Boolean {
}
/**
* Returns a progression from this value down to the specified [to] value with the increment -1.
* Returns a progression from this value down to the specified [to] value with the step -1.
* The [to] value has to be less than this value.
*/
public infix fun Int.downTo(to: Byte): IntProgression {
@@ -585,7 +585,7 @@ public infix fun Int.downTo(to: Byte): IntProgression {
}
/**
* Returns a progression from this value down to the specified [to] value with the increment -1.
* Returns a progression from this value down to the specified [to] value with the step -1.
* The [to] value has to be less than this value.
*/
public infix fun Long.downTo(to: Byte): LongProgression {
@@ -593,7 +593,7 @@ public infix fun Long.downTo(to: Byte): LongProgression {
}
/**
* Returns a progression from this value down to the specified [to] value with the increment -1.
* Returns a progression from this value down to the specified [to] value with the step -1.
* The [to] value has to be less than this value.
*/
public infix fun Byte.downTo(to: Byte): IntProgression {
@@ -601,7 +601,7 @@ public infix fun Byte.downTo(to: Byte): IntProgression {
}
/**
* Returns a progression from this value down to the specified [to] value with the increment -1.
* Returns a progression from this value down to the specified [to] value with the step -1.
* The [to] value has to be less than this value.
*/
public infix fun Short.downTo(to: Byte): IntProgression {
@@ -609,7 +609,7 @@ public infix fun Short.downTo(to: Byte): IntProgression {
}
/**
* Returns a progression from this value down to the specified [to] value with the increment -1.
* Returns a progression from this value down to the specified [to] value with the step -1.
* The [to] value has to be less than this value.
*/
public infix fun Char.downTo(to: Char): CharProgression {
@@ -617,7 +617,7 @@ public infix fun Char.downTo(to: Char): CharProgression {
}
/**
* Returns a progression from this value down to the specified [to] value with the increment -1.
* Returns a progression from this value down to the specified [to] value with the step -1.
* The [to] value has to be less than this value.
*/
public infix fun Int.downTo(to: Int): IntProgression {
@@ -625,7 +625,7 @@ public infix fun Int.downTo(to: Int): IntProgression {
}
/**
* Returns a progression from this value down to the specified [to] value with the increment -1.
* Returns a progression from this value down to the specified [to] value with the step -1.
* The [to] value has to be less than this value.
*/
public infix fun Long.downTo(to: Int): LongProgression {
@@ -633,7 +633,7 @@ public infix fun Long.downTo(to: Int): LongProgression {
}
/**
* Returns a progression from this value down to the specified [to] value with the increment -1.
* Returns a progression from this value down to the specified [to] value with the step -1.
* The [to] value has to be less than this value.
*/
public infix fun Byte.downTo(to: Int): IntProgression {
@@ -641,7 +641,7 @@ public infix fun Byte.downTo(to: Int): IntProgression {
}
/**
* Returns a progression from this value down to the specified [to] value with the increment -1.
* Returns a progression from this value down to the specified [to] value with the step -1.
* The [to] value has to be less than this value.
*/
public infix fun Short.downTo(to: Int): IntProgression {
@@ -649,7 +649,7 @@ public infix fun Short.downTo(to: Int): IntProgression {
}
/**
* Returns a progression from this value down to the specified [to] value with the increment -1.
* Returns a progression from this value down to the specified [to] value with the step -1.
* The [to] value has to be less than this value.
*/
public infix fun Int.downTo(to: Long): LongProgression {
@@ -657,7 +657,7 @@ public infix fun Int.downTo(to: Long): LongProgression {
}
/**
* Returns a progression from this value down to the specified [to] value with the increment -1.
* Returns a progression from this value down to the specified [to] value with the step -1.
* The [to] value has to be less than this value.
*/
public infix fun Long.downTo(to: Long): LongProgression {
@@ -665,7 +665,7 @@ public infix fun Long.downTo(to: Long): LongProgression {
}
/**
* Returns a progression from this value down to the specified [to] value with the increment -1.
* Returns a progression from this value down to the specified [to] value with the step -1.
* The [to] value has to be less than this value.
*/
public infix fun Byte.downTo(to: Long): LongProgression {
@@ -673,7 +673,7 @@ public infix fun Byte.downTo(to: Long): LongProgression {
}
/**
* Returns a progression from this value down to the specified [to] value with the increment -1.
* Returns a progression from this value down to the specified [to] value with the step -1.
* The [to] value has to be less than this value.
*/
public infix fun Short.downTo(to: Long): LongProgression {
@@ -681,7 +681,7 @@ public infix fun Short.downTo(to: Long): LongProgression {
}
/**
* Returns a progression from this value down to the specified [to] value with the increment -1.
* Returns a progression from this value down to the specified [to] value with the step -1.
* The [to] value has to be less than this value.
*/
public infix fun Int.downTo(to: Short): IntProgression {
@@ -689,7 +689,7 @@ public infix fun Int.downTo(to: Short): IntProgression {
}
/**
* Returns a progression from this value down to the specified [to] value with the increment -1.
* Returns a progression from this value down to the specified [to] value with the step -1.
* The [to] value has to be less than this value.
*/
public infix fun Long.downTo(to: Short): LongProgression {
@@ -697,7 +697,7 @@ public infix fun Long.downTo(to: Short): LongProgression {
}
/**
* Returns a progression from this value down to the specified [to] value with the increment -1.
* Returns a progression from this value down to the specified [to] value with the step -1.
* The [to] value has to be less than this value.
*/
public infix fun Byte.downTo(to: Short): IntProgression {
@@ -705,7 +705,7 @@ public infix fun Byte.downTo(to: Short): IntProgression {
}
/**
* Returns a progression from this value down to the specified [to] value with the increment -1.
* Returns a progression from this value down to the specified [to] value with the step -1.
* The [to] value has to be less than this value.
*/
public infix fun Short.downTo(to: Short): IntProgression {
@@ -716,21 +716,21 @@ public infix fun Short.downTo(to: Short): IntProgression {
* Returns a progression that goes over the same range in the opposite direction with the same step.
*/
public fun CharProgression.reversed(): CharProgression {
return CharProgression.fromClosedRange(last, first, -increment)
return CharProgression.fromClosedRange(last, first, -step)
}
/**
* Returns a progression that goes over the same range in the opposite direction with the same step.
*/
public fun IntProgression.reversed(): IntProgression {
return IntProgression.fromClosedRange(last, first, -increment)
return IntProgression.fromClosedRange(last, first, -step)
}
/**
* Returns a progression that goes over the same range in the opposite direction with the same step.
*/
public fun LongProgression.reversed(): LongProgression {
return LongProgression.fromClosedRange(last, first, -increment)
return LongProgression.fromClosedRange(last, first, -step)
}
/**
@@ -763,7 +763,7 @@ public fun LongRange.reversed(): LongProgression {
@Deprecated("This range implementation has unclear semantics and will be removed soon.")
@Suppress("DEPRECATION_ERROR")
public fun ByteProgression.reversed(): ByteProgression {
return ByteProgression.fromClosedRange(last, first, -increment)
return ByteProgression.fromClosedRange(last, first, -step)
}
/**
@@ -772,7 +772,7 @@ public fun ByteProgression.reversed(): ByteProgression {
@Deprecated("This range implementation has unclear semantics and will be removed soon.")
@Suppress("DEPRECATION_ERROR")
public fun ShortProgression.reversed(): ShortProgression {
return ShortProgression.fromClosedRange(last, first, -increment)
return ShortProgression.fromClosedRange(last, first, -step)
}
/**
@@ -798,7 +798,7 @@ public fun ShortRange.reversed(): ShortProgression {
*/
public infix fun CharProgression.step(step: Int): CharProgression {
checkStepIsPositive(step > 0, step)
return CharProgression.fromClosedRange(first, last, if (increment > 0) step else -step)
return CharProgression.fromClosedRange(first, last, if (this.step > 0) step else -step)
}
/**
@@ -806,7 +806,7 @@ public infix fun CharProgression.step(step: Int): CharProgression {
*/
public infix fun IntProgression.step(step: Int): IntProgression {
checkStepIsPositive(step > 0, step)
return IntProgression.fromClosedRange(first, last, if (increment > 0) step else -step)
return IntProgression.fromClosedRange(first, last, if (this.step > 0) step else -step)
}
/**
@@ -814,7 +814,7 @@ public infix fun IntProgression.step(step: Int): IntProgression {
*/
public infix fun LongProgression.step(step: Long): LongProgression {
checkStepIsPositive(step > 0, step)
return LongProgression.fromClosedRange(first, last, if (increment > 0) step else -step)
return LongProgression.fromClosedRange(first, last, if (this.step > 0) step else -step)
}
/**
@@ -851,7 +851,7 @@ public infix fun LongRange.step(step: Long): LongProgression {
@Suppress("DEPRECATION_ERROR")
public infix fun ByteProgression.step(step: Int): ByteProgression {
checkStepIsPositive(step > 0, step)
return ByteProgression.fromClosedRange(first, last, if (increment > 0) step else -step)
return ByteProgression.fromClosedRange(first, last, if (this.step > 0) step else -step)
}
/**
@@ -861,7 +861,7 @@ public infix fun ByteProgression.step(step: Int): ByteProgression {
@Suppress("DEPRECATION_ERROR")
public infix fun ShortProgression.step(step: Int): ShortProgression {
checkStepIsPositive(step > 0, step)
return ShortProgression.fromClosedRange(first, last, if (increment > 0) step else -step)
return ShortProgression.fromClosedRange(first, last, if (this.step > 0) step else -step)
}
/**
@@ -19,17 +19,17 @@ public open class RangeIterationTestBase {
is IntProgression -> {
first = sequence.first
last = sequence.last
increment = sequence.increment
increment = sequence.step
}
is LongProgression -> {
first = sequence.first
last = sequence.last
increment = sequence.increment
increment = sequence.step
}
is CharProgression -> {
first = sequence.first
last = sequence.last
increment = sequence.increment
increment = sequence.step
}
// TODO: Drop this branch
is Progression -> {
@@ -24,7 +24,7 @@ fun ranges(): List<GenericFunction> {
"return TProgression.fromClosedRange(last, first, -ONE)"
}
body(ProgressionsOfPrimitives) {
"return TProgression.fromClosedRange(last, first, -increment)"
"return TProgression.fromClosedRange(last, first, -step)"
}
}
@@ -41,7 +41,7 @@ fun ranges(): List<GenericFunction> {
"return TProgression.fromClosedRange(last, first, -ONE)"
}
body(ProgressionsOfPrimitives) {
"return TProgression.fromClosedRange(last, first, -increment)"
"return TProgression.fromClosedRange(last, first, -step)"
}
}
@@ -63,7 +63,7 @@ fun ranges(): List<GenericFunction> {
body(ProgressionsOfPrimitives) {
"""
checkStepIsPositive(step > 0, step)
return TProgression.fromClosedRange(first, last, if (increment > 0) step else -step)
return TProgression.fromClosedRange(first, last, if (this.step > 0) step else -step)
"""
}
}
@@ -95,7 +95,7 @@ fun ranges(): List<GenericFunction> {
body(ProgressionsOfPrimitives) {
"""
checkStepIsPositive(step > 0, step)
return TProgression.fromClosedRange(first, last, if (increment > 0) step else -step)
return TProgression.fromClosedRange(first, last, if (this.step > 0) step else -step)
"""
}
}
@@ -113,7 +113,7 @@ fun ranges(): List<GenericFunction> {
doc {
"""
Returns a progression from this value down to the specified [to] value with the increment -1.
Returns a progression from this value down to the specified [to] value with the step -1.
The [to] value has to be less than this value.
"""
}