diff --git a/core/builtins/src/kotlin/Progressions.kt b/core/builtins/src/kotlin/Progressions.kt index 366285f1076..9e8bc8b9f66 100644 --- a/core/builtins/src/kotlin/Progressions.kt +++ b/core/builtins/src/kotlin/Progressions.kt @@ -41,7 +41,12 @@ public open class CharProgression override fun iterator(): CharIterator = CharProgressionIterator(first, last, step) - /** Checks if the progression is empty. */ + /** + * Checks if the progression is empty. + + * Progression with a positive step is empty if its first element is greater than the last element. + * Progression with a negative step is empty if its first element is less than the last element. + */ public open fun isEmpty(): Boolean = if (step > 0) first > last else first < last override fun equals(other: Any?): Boolean = @@ -98,7 +103,12 @@ public open class IntProgression override fun iterator(): IntIterator = IntProgressionIterator(first, last, step) - /** Checks if the progression is empty. */ + /** + * Checks if the progression is empty. + + * Progression with a positive step is empty if its first element is greater than the last element. + * Progression with a negative step is empty if its first element is less than the last element. + */ public open fun isEmpty(): Boolean = if (step > 0) first > last else first < last override fun equals(other: Any?): Boolean = @@ -155,7 +165,12 @@ public open class LongProgression override fun iterator(): LongIterator = LongProgressionIterator(first, last, step) - /** Checks if the progression is empty. */ + /** + * Checks if the progression is empty. + + * Progression with a positive step is empty if its first element is greater than the last element. + * Progression with a negative step is empty if its first element is less than the last element. + */ public open fun isEmpty(): Boolean = if (step > 0) first > last else first < last override fun equals(other: Any?): Boolean = diff --git a/core/builtins/src/kotlin/Range.kt b/core/builtins/src/kotlin/Range.kt index 4e036fcbad9..66f03e97bff 100644 --- a/core/builtins/src/kotlin/Range.kt +++ b/core/builtins/src/kotlin/Range.kt @@ -27,6 +27,8 @@ public interface ClosedRange> { /** * Checks whether the range is empty. + + * The range is empty if its start value is greater than the end value. */ public fun isEmpty(): Boolean = start > endInclusive } diff --git a/core/builtins/src/kotlin/Ranges.kt b/core/builtins/src/kotlin/Ranges.kt index 3c85fef2116..661acaa125c 100644 --- a/core/builtins/src/kotlin/Ranges.kt +++ b/core/builtins/src/kotlin/Ranges.kt @@ -16,6 +16,11 @@ public class CharRange(start: Char, endInclusive: Char) : CharProgression(start, override fun contains(value: Char): Boolean = first <= value && value <= last + /** + * Checks whether the range is empty. + + * The range is empty if its start value is greater than the end value. + */ override fun isEmpty(): Boolean = first > last override fun equals(other: Any?): Boolean = @@ -42,6 +47,11 @@ public class IntRange(start: Int, endInclusive: Int) : IntProgression(start, end override fun contains(value: Int): Boolean = first <= value && value <= last + /** + * Checks whether the range is empty. + + * The range is empty if its start value is greater than the end value. + */ override fun isEmpty(): Boolean = first > last override fun equals(other: Any?): Boolean = @@ -68,6 +78,11 @@ public class LongRange(start: Long, endInclusive: Long) : LongProgression(start, override fun contains(value: Long): Boolean = first <= value && value <= last + /** + * Checks whether the range is empty. + + * The range is empty if its start value is greater than the end value. + */ override fun isEmpty(): Boolean = first > last override fun equals(other: Any?): Boolean = diff --git a/generators/builtins/progressions.kt b/generators/builtins/progressions.kt index 1b9ca8818b2..b93a66a7e5d 100644 --- a/generators/builtins/progressions.kt +++ b/generators/builtins/progressions.kt @@ -82,7 +82,12 @@ public open class $progression override fun iterator(): ${t}Iterator = ${t}ProgressionIterator(first, last, step) - /** Checks if the progression is empty. */ + /** + * Checks if the progression is empty. + + * Progression with a positive step is empty if its first element is greater than the last element. + * Progression with a negative step is empty if its first element is less than the last element. + */ public open fun isEmpty(): Boolean = if (step > 0) first > last else first < last override fun equals(other: Any?): Boolean = diff --git a/generators/builtins/ranges.kt b/generators/builtins/ranges.kt index 93709242ce5..036aaa66a17 100644 --- a/generators/builtins/ranges.kt +++ b/generators/builtins/ranges.kt @@ -58,6 +58,11 @@ public class $range(start: $t, endInclusive: $t) : ${t}Progression(start, endInc override fun contains(value: $t): Boolean = first <= value && value <= last + /** + * Checks whether the range is empty. + + * The range is empty if its start value is greater than the end value. + */ override fun isEmpty(): Boolean = first > last override fun equals(other: Any?): Boolean = diff --git a/generators/builtins/unsignedTypes.kt b/generators/builtins/unsignedTypes.kt index 84435646e58..f55df034b6c 100644 --- a/generators/builtins/unsignedTypes.kt +++ b/generators/builtins/unsignedTypes.kt @@ -587,6 +587,11 @@ public class ${elementType}Range(start: $elementType, endInclusive: $elementType override fun contains(value: $elementType): Boolean = first <= value && value <= last + /** + * Checks if the range is empty. + + * The range is empty if its start value is greater than the end value. + */ override fun isEmpty(): Boolean = first > last override fun equals(other: Any?): Boolean = @@ -637,7 +642,12 @@ internal constructor( override fun iterator(): ${elementType}Iterator = ${elementType}ProgressionIterator(first, last, step) - /** Checks if the progression is empty. */ + /** + * Checks if the progression is empty. + + * Progression with a positive step is empty if its first element is greater than the last element. + * Progression with a negative step is empty if its first element is less than the last element. + */ public open fun isEmpty(): Boolean = if (step > 0) first > last else first < last override fun equals(other: Any?): Boolean = diff --git a/libraries/stdlib/unsigned/src/kotlin/UIntRange.kt b/libraries/stdlib/unsigned/src/kotlin/UIntRange.kt index 521f61e047c..1d6a52bb2f6 100644 --- a/libraries/stdlib/unsigned/src/kotlin/UIntRange.kt +++ b/libraries/stdlib/unsigned/src/kotlin/UIntRange.kt @@ -22,6 +22,11 @@ public class UIntRange(start: UInt, endInclusive: UInt) : UIntProgression(start, override fun contains(value: UInt): Boolean = first <= value && value <= last + /** + * Checks if the range is empty. + + * The range is empty if its start value is greater than the end value. + */ override fun isEmpty(): Boolean = first > last override fun equals(other: Any?): Boolean = @@ -72,7 +77,12 @@ internal constructor( override fun iterator(): UIntIterator = UIntProgressionIterator(first, last, step) - /** Checks if the progression is empty. */ + /** + * Checks if the progression is empty. + + * Progression with a positive step is empty if its first element is greater than the last element. + * Progression with a negative step is empty if its first element is less than the last element. + */ public open fun isEmpty(): Boolean = if (step > 0) first > last else first < last override fun equals(other: Any?): Boolean = diff --git a/libraries/stdlib/unsigned/src/kotlin/ULongRange.kt b/libraries/stdlib/unsigned/src/kotlin/ULongRange.kt index de833930884..787690845fa 100644 --- a/libraries/stdlib/unsigned/src/kotlin/ULongRange.kt +++ b/libraries/stdlib/unsigned/src/kotlin/ULongRange.kt @@ -22,6 +22,11 @@ public class ULongRange(start: ULong, endInclusive: ULong) : ULongProgression(st override fun contains(value: ULong): Boolean = first <= value && value <= last + /** + * Checks if the range is empty. + + * The range is empty if its start value is greater than the end value. + */ override fun isEmpty(): Boolean = first > last override fun equals(other: Any?): Boolean = @@ -72,7 +77,12 @@ internal constructor( override fun iterator(): ULongIterator = ULongProgressionIterator(first, last, step) - /** Checks if the progression is empty. */ + /** + * Checks if the progression is empty. + + * Progression with a positive step is empty if its first element is greater than the last element. + * Progression with a negative step is empty if its first element is less than the last element. + */ public open fun isEmpty(): Boolean = if (step > 0) first > last else first < last override fun equals(other: Any?): Boolean =