org.nield.kotlinstatistics.range.ClosedOpenRange.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-statistics Show documentation
Show all versions of kotlin-statistics Show documentation
Statistical and analytical extensions for Kotlin
package org.nield.kotlinstatistics.range
class ClosedOpenRange>(val startInclusive: T, val endExclusive: T): Range {
init {
if (startInclusive > endExclusive) throw InvalidRangeException("($startInclusive..$endExclusive] is an invalid ClosedOpenRange!")
}
override val lowerBound get() = startInclusive
override val upperBound get() = endExclusive
override fun contains(value: T) = value >= startInclusive && value < endExclusive
override fun isEmpty() = endExclusive == startInclusive
override fun toString() = "[$startInclusive..$endExclusive)"
}
infix fun > T.until(endExclusive: T) = ClosedOpenRange(this, endExclusive)
fun > XClosedRange.toClosedOpenRange() = ClosedOpenRange(start,endInclusive)