Add *Range.isEmpty(), *Progression.isEmpty()
This commit is contained in:
@@ -141,6 +141,7 @@ public final class ByteProgression : kotlin.Progression<kotlin.Byte> {
|
||||
public open override /*1*/ fun <get-increment>(): kotlin.Int
|
||||
public open override /*1*/ val start: kotlin.Byte
|
||||
public open override /*1*/ fun <get-start>(): kotlin.Byte
|
||||
public final fun isEmpty(): kotlin.Boolean
|
||||
public open override /*1*/ fun iterator(): kotlin.ByteIterator
|
||||
}
|
||||
|
||||
@@ -170,6 +171,7 @@ public final class ByteRange : kotlin.Range<kotlin.Byte>, kotlin.Progression<kot
|
||||
public open override /*2*/ val start: kotlin.Byte
|
||||
public open override /*2*/ fun <get-start>(): kotlin.Byte
|
||||
public open override /*1*/ fun contains(/*0*/ item: kotlin.Byte): kotlin.Boolean
|
||||
public open override /*1*/ fun isEmpty(): kotlin.Boolean
|
||||
public open override /*1*/ fun iterator(): kotlin.ByteIterator
|
||||
|
||||
public class object <class-object-for-ByteRange> {
|
||||
@@ -259,6 +261,7 @@ public final class CharProgression : kotlin.Progression<kotlin.Char> {
|
||||
public open override /*1*/ fun <get-increment>(): kotlin.Int
|
||||
public open override /*1*/ val start: kotlin.Char
|
||||
public open override /*1*/ fun <get-start>(): kotlin.Char
|
||||
public final fun isEmpty(): kotlin.Boolean
|
||||
public open override /*1*/ fun iterator(): kotlin.CharIterator
|
||||
}
|
||||
|
||||
@@ -288,6 +291,7 @@ public final class CharRange : kotlin.Range<kotlin.Char>, kotlin.Progression<kot
|
||||
public open override /*2*/ val start: kotlin.Char
|
||||
public open override /*2*/ fun <get-start>(): kotlin.Char
|
||||
public open override /*1*/ fun contains(/*0*/ item: kotlin.Char): kotlin.Boolean
|
||||
public open override /*1*/ fun isEmpty(): kotlin.Boolean
|
||||
public open override /*1*/ fun iterator(): kotlin.CharIterator
|
||||
|
||||
public class object <class-object-for-CharRange> {
|
||||
@@ -404,6 +408,7 @@ public final class DoubleProgression : kotlin.Progression<kotlin.Double> {
|
||||
public open override /*1*/ fun <get-increment>(): kotlin.Double
|
||||
public open override /*1*/ val start: kotlin.Double
|
||||
public open override /*1*/ fun <get-start>(): kotlin.Double
|
||||
public final fun isEmpty(): kotlin.Boolean
|
||||
public open override /*1*/ fun iterator(): kotlin.DoubleIterator
|
||||
}
|
||||
|
||||
@@ -430,6 +435,7 @@ public final class DoubleRange : kotlin.Range<kotlin.Double>, kotlin.Progression
|
||||
public open override /*2*/ val start: kotlin.Double
|
||||
public open override /*2*/ fun <get-start>(): kotlin.Double
|
||||
public open override /*1*/ fun contains(/*0*/ item: kotlin.Double): kotlin.Boolean
|
||||
public open override /*1*/ fun isEmpty(): kotlin.Boolean
|
||||
public open override /*1*/ fun iterator(): kotlin.DoubleIterator
|
||||
|
||||
public class object <class-object-for-DoubleRange> {
|
||||
@@ -627,6 +633,7 @@ public final class FloatProgression : kotlin.Progression<kotlin.Float> {
|
||||
public open override /*1*/ fun <get-increment>(): kotlin.Float
|
||||
public open override /*1*/ val start: kotlin.Float
|
||||
public open override /*1*/ fun <get-start>(): kotlin.Float
|
||||
public final fun isEmpty(): kotlin.Boolean
|
||||
public open override /*1*/ fun iterator(): kotlin.FloatIterator
|
||||
}
|
||||
|
||||
@@ -653,6 +660,7 @@ public final class FloatRange : kotlin.Range<kotlin.Float>, kotlin.Progression<k
|
||||
public open override /*2*/ val start: kotlin.Float
|
||||
public open override /*2*/ fun <get-start>(): kotlin.Float
|
||||
public open override /*1*/ fun contains(/*0*/ item: kotlin.Float): kotlin.Boolean
|
||||
public open override /*1*/ fun isEmpty(): kotlin.Boolean
|
||||
public open override /*1*/ fun iterator(): kotlin.FloatIterator
|
||||
|
||||
public class object <class-object-for-FloatRange> {
|
||||
@@ -887,6 +895,7 @@ public final class IntProgression : kotlin.Progression<kotlin.Int> {
|
||||
public open override /*1*/ fun <get-increment>(): kotlin.Int
|
||||
public open override /*1*/ val start: kotlin.Int
|
||||
public open override /*1*/ fun <get-start>(): kotlin.Int
|
||||
public final fun isEmpty(): kotlin.Boolean
|
||||
public open override /*1*/ fun iterator(): kotlin.IntIterator
|
||||
}
|
||||
|
||||
@@ -916,6 +925,7 @@ public final class IntRange : kotlin.Range<kotlin.Int>, kotlin.Progression<kotli
|
||||
public open override /*2*/ val start: kotlin.Int
|
||||
public open override /*2*/ fun <get-start>(): kotlin.Int
|
||||
public open override /*1*/ fun contains(/*0*/ item: kotlin.Int): kotlin.Boolean
|
||||
public open override /*1*/ fun isEmpty(): kotlin.Boolean
|
||||
public open override /*1*/ fun iterator(): kotlin.IntIterator
|
||||
|
||||
public class object <class-object-for-IntRange> {
|
||||
@@ -1054,6 +1064,7 @@ public final class LongProgression : kotlin.Progression<kotlin.Long> {
|
||||
public open override /*1*/ fun <get-increment>(): kotlin.Long
|
||||
public open override /*1*/ val start: kotlin.Long
|
||||
public open override /*1*/ fun <get-start>(): kotlin.Long
|
||||
public final fun isEmpty(): kotlin.Boolean
|
||||
public open override /*1*/ fun iterator(): kotlin.LongIterator
|
||||
}
|
||||
|
||||
@@ -1083,6 +1094,7 @@ public final class LongRange : kotlin.Range<kotlin.Long>, kotlin.Progression<kot
|
||||
public open override /*2*/ val start: kotlin.Long
|
||||
public open override /*2*/ fun <get-start>(): kotlin.Long
|
||||
public open override /*1*/ fun contains(/*0*/ item: kotlin.Long): kotlin.Boolean
|
||||
public open override /*1*/ fun isEmpty(): kotlin.Boolean
|
||||
public open override /*1*/ fun iterator(): kotlin.LongIterator
|
||||
|
||||
public class object <class-object-for-LongRange> {
|
||||
@@ -1245,6 +1257,7 @@ public trait Range</*0*/ T : kotlin.Comparable<T>> {
|
||||
public abstract val start: T
|
||||
public abstract fun <get-start>(): T
|
||||
public abstract fun contains(/*0*/ item: T): kotlin.Boolean
|
||||
public open fun isEmpty(): kotlin.Boolean
|
||||
}
|
||||
|
||||
public trait Set</*0*/ out E> : kotlin.Collection<E> {
|
||||
@@ -1345,6 +1358,7 @@ public final class ShortProgression : kotlin.Progression<kotlin.Short> {
|
||||
public open override /*1*/ fun <get-increment>(): kotlin.Int
|
||||
public open override /*1*/ val start: kotlin.Short
|
||||
public open override /*1*/ fun <get-start>(): kotlin.Short
|
||||
public final fun isEmpty(): kotlin.Boolean
|
||||
public open override /*1*/ fun iterator(): kotlin.ShortIterator
|
||||
}
|
||||
|
||||
@@ -1374,6 +1388,7 @@ public final class ShortRange : kotlin.Range<kotlin.Short>, kotlin.Progression<k
|
||||
public open override /*2*/ val start: kotlin.Short
|
||||
public open override /*2*/ fun <get-start>(): kotlin.Short
|
||||
public open override /*1*/ fun contains(/*0*/ item: kotlin.Short): kotlin.Boolean
|
||||
public open override /*1*/ fun isEmpty(): kotlin.Boolean
|
||||
public open override /*1*/ fun iterator(): kotlin.ShortIterator
|
||||
|
||||
public class object <class-object-for-ShortRange> {
|
||||
|
||||
@@ -29,6 +29,8 @@ public class ByteProgression(
|
||||
|
||||
override fun iterator(): ByteIterator = ByteProgressionIterator(start, end, increment)
|
||||
|
||||
public fun isEmpty(): Boolean = if (increment > 0) start > end else start < end
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is ByteProgression && start == other.start && end == other.end && increment == other.increment
|
||||
|
||||
@@ -48,6 +50,8 @@ public class CharProgression(
|
||||
|
||||
override fun iterator(): CharIterator = CharProgressionIterator(start, end, increment)
|
||||
|
||||
public fun isEmpty(): Boolean = if (increment > 0) start > end else start < end
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is CharProgression && start == other.start && end == other.end && increment == other.increment
|
||||
|
||||
@@ -67,6 +71,8 @@ public class ShortProgression(
|
||||
|
||||
override fun iterator(): ShortIterator = ShortProgressionIterator(start, end, increment)
|
||||
|
||||
public fun isEmpty(): Boolean = if (increment > 0) start > end else start < end
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is ShortProgression && start == other.start && end == other.end && increment == other.increment
|
||||
|
||||
@@ -86,6 +92,8 @@ public class IntProgression(
|
||||
|
||||
override fun iterator(): IntIterator = IntProgressionIterator(start, end, increment)
|
||||
|
||||
public fun isEmpty(): Boolean = if (increment > 0) start > end else start < end
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is IntProgression && start == other.start && end == other.end && increment == other.increment
|
||||
|
||||
@@ -105,6 +113,8 @@ public class LongProgression(
|
||||
|
||||
override fun iterator(): LongIterator = LongProgressionIterator(start, end, increment)
|
||||
|
||||
public fun isEmpty(): Boolean = if (increment > 0) start > end else start < end
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is LongProgression && start == other.start && end == other.end && increment == other.increment
|
||||
|
||||
@@ -125,6 +135,8 @@ public class FloatProgression(
|
||||
|
||||
override fun iterator(): FloatIterator = FloatProgressionIterator(start, end, increment)
|
||||
|
||||
public fun isEmpty(): Boolean = if (increment > 0) start > end else start < end
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is FloatProgression && java.lang.Float.compare(start, other.start) == 0 && java.lang.Float.compare(end, other.end) == 0 && java.lang.Float.compare(increment, other.increment) == 0
|
||||
|
||||
@@ -145,6 +157,8 @@ public class DoubleProgression(
|
||||
|
||||
override fun iterator(): DoubleIterator = DoubleProgressionIterator(start, end, increment)
|
||||
|
||||
public fun isEmpty(): Boolean = if (increment > 0) start > end else start < end
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is DoubleProgression && java.lang.Double.compare(start, other.start) == 0 && java.lang.Double.compare(end, other.end) == 0 && java.lang.Double.compare(increment, other.increment) == 0
|
||||
|
||||
|
||||
@@ -23,5 +23,7 @@ public trait Range<T : Comparable<T>> {
|
||||
|
||||
public fun contains(item: T): Boolean
|
||||
|
||||
public fun isEmpty(): Boolean = start > end
|
||||
|
||||
override fun toString(): String = "$start..$end"
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ public class ByteRange(public override val start: Byte, public override val end:
|
||||
|
||||
override fun iterator(): ByteIterator = ByteProgressionIterator(start, end, 1)
|
||||
|
||||
override fun isEmpty(): Boolean = start > end
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is ByteRange && start == other.start && end == other.end
|
||||
|
||||
@@ -44,6 +46,8 @@ public class CharRange(public override val start: Char, public override val end:
|
||||
|
||||
override fun iterator(): CharIterator = CharProgressionIterator(start, end, 1)
|
||||
|
||||
override fun isEmpty(): Boolean = start > end
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is CharRange && start == other.start && end == other.end
|
||||
|
||||
@@ -62,6 +66,8 @@ public class ShortRange(public override val start: Short, public override val en
|
||||
|
||||
override fun iterator(): ShortIterator = ShortProgressionIterator(start, end, 1)
|
||||
|
||||
override fun isEmpty(): Boolean = start > end
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is ShortRange && start == other.start && end == other.end
|
||||
|
||||
@@ -80,6 +86,8 @@ public class IntRange(public override val start: Int, public override val end: I
|
||||
|
||||
override fun iterator(): IntIterator = IntProgressionIterator(start, end, 1)
|
||||
|
||||
override fun isEmpty(): Boolean = start > end
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is IntRange && start == other.start && end == other.end
|
||||
|
||||
@@ -98,6 +106,8 @@ public class LongRange(public override val start: Long, public override val end:
|
||||
|
||||
override fun iterator(): LongIterator = LongProgressionIterator(start, end, 1)
|
||||
|
||||
override fun isEmpty(): Boolean = start > end
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is LongRange && start == other.start && end == other.end
|
||||
|
||||
@@ -116,6 +126,8 @@ public class FloatRange(public override val start: Float, public override val en
|
||||
|
||||
override fun iterator(): FloatIterator = FloatProgressionIterator(start, end, 1.0f)
|
||||
|
||||
override fun isEmpty(): Boolean = start > end
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is FloatRange && java.lang.Float.compare(start, other.start) == 0 && java.lang.Float.compare(end, other.end) == 0
|
||||
|
||||
@@ -134,6 +146,8 @@ public class DoubleRange(public override val start: Double, public override val
|
||||
|
||||
override fun iterator(): DoubleIterator = DoubleProgressionIterator(start, end, 1.0)
|
||||
|
||||
override fun isEmpty(): Boolean = start > end
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is DoubleRange && java.lang.Double.compare(start, other.start) == 0 && java.lang.Double.compare(end, other.end) == 0
|
||||
|
||||
|
||||
@@ -71,6 +71,8 @@ class GenerateProgressions(out: PrintWriter) : BuiltInsSourceGenerator(out) {
|
||||
|
||||
override fun iterator(): ${t}Iterator = ${t}ProgressionIterator(start, end, increment)
|
||||
|
||||
public fun isEmpty(): Boolean = if (increment > 0) start > end else start < end
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is $progression && ${compare("start")} && ${compare("end")} && ${compare("increment")}
|
||||
|
||||
|
||||
@@ -66,6 +66,8 @@ class GenerateRanges(out: PrintWriter) : BuiltInsSourceGenerator(out) {
|
||||
|
||||
override fun iterator(): ${t}Iterator = ${t}ProgressionIterator(start, end, $increment)
|
||||
|
||||
override fun isEmpty(): Boolean = start > end
|
||||
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is $range && ${compare("start")} && ${compare("end")}
|
||||
|
||||
|
||||
@@ -543,6 +543,9 @@
|
||||
},
|
||||
iterator: function () {
|
||||
return new Kotlin.RangeIterator(this.start, this.end, this.increment);
|
||||
},
|
||||
isEmpty: function () {
|
||||
return this.start > this.end;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -554,6 +557,9 @@
|
||||
}, {
|
||||
iterator: function () {
|
||||
return new Kotlin.RangeIterator(this.start, this.end, this.increment);
|
||||
},
|
||||
isEmpty: function() {
|
||||
return this.increment > 0 ? this.start > this.end : this.start < this.end;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ public class RangeTest {
|
||||
|
||||
assertFalse(10 in range)
|
||||
assertFalse(9000 in range)
|
||||
|
||||
assertFalse(range.isEmpty())
|
||||
}
|
||||
|
||||
test fun byteRange() {
|
||||
@@ -34,6 +36,8 @@ public class RangeTest {
|
||||
|
||||
assertFalse(10.toByte() in range)
|
||||
assertFalse(111.toByte() in range)
|
||||
|
||||
assertFalse(range.isEmpty())
|
||||
}
|
||||
|
||||
test fun shortRange() {
|
||||
@@ -50,6 +54,8 @@ public class RangeTest {
|
||||
|
||||
assertFalse(10.toShort() in range)
|
||||
assertFalse(239.toShort() in range)
|
||||
|
||||
assertFalse(range.isEmpty())
|
||||
}
|
||||
|
||||
test fun longRange() {
|
||||
@@ -66,6 +72,8 @@ public class RangeTest {
|
||||
|
||||
assertFalse(10.toLong() in range)
|
||||
assertFalse(10000000.toLong() in range)
|
||||
|
||||
assertFalse(range.isEmpty())
|
||||
}
|
||||
|
||||
test fun charRange() {
|
||||
@@ -82,6 +90,8 @@ public class RangeTest {
|
||||
|
||||
assertFalse('z' in range)
|
||||
assertFalse('\u1000' in range)
|
||||
|
||||
assertFalse(range.isEmpty())
|
||||
}
|
||||
|
||||
test fun doubleRange() {
|
||||
@@ -100,6 +110,8 @@ public class RangeTest {
|
||||
assertFalse(3.15 in range)
|
||||
assertFalse(10.0 in range)
|
||||
assertFalse(1e200 in range)
|
||||
|
||||
assertFalse(range.isEmpty())
|
||||
}
|
||||
|
||||
test fun floatRange() {
|
||||
@@ -118,6 +130,27 @@ public class RangeTest {
|
||||
assertFalse(3.15.toFloat() in range)
|
||||
assertFalse(10.0.toFloat() in range)
|
||||
assertFalse(1e30.toFloat() in range)
|
||||
|
||||
assertFalse(range.isEmpty())
|
||||
}
|
||||
|
||||
test fun isEmpty() {
|
||||
assertTrue((2..1).isEmpty())
|
||||
assertTrue((2L..0L).isEmpty())
|
||||
assertTrue((1.toShort()..-1.toShort()).isEmpty())
|
||||
assertTrue((0.toByte()..-1.toByte()).isEmpty())
|
||||
assertTrue((0f..-3.14f).isEmpty())
|
||||
assertTrue((-2.72..-3.14).isEmpty())
|
||||
assertTrue(('z'..'x').isEmpty())
|
||||
|
||||
assertTrue((1 downTo 2).isEmpty())
|
||||
assertTrue((0L downTo 2L).isEmpty())
|
||||
assertFalse((2 downTo 1).isEmpty())
|
||||
assertFalse((2L downTo 0L).isEmpty())
|
||||
assertTrue(('a' downTo 'z').isEmpty())
|
||||
assertTrue(('z'..'a' step 2).isEmpty())
|
||||
|
||||
assertTrue(("range".."progression").isEmpty())
|
||||
}
|
||||
|
||||
test fun comparableRange() {
|
||||
@@ -131,5 +164,7 @@ public class RangeTest {
|
||||
|
||||
assertFalse("item" in range)
|
||||
assertFalse("trail" in range)
|
||||
|
||||
assertFalse(range.isEmpty())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user