org.nield.kotlinstatistics.range.OpenRange.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 OpenRange>(val startExclusive: T, val endExclusive: T): Range {
init {
if (startExclusive == endExclusive ||
startExclusive > endExclusive) throw InvalidRangeException("($startExclusive..$endExclusive) is an invalid OpenRange!")
}
override val lowerBound get() = startExclusive
override val upperBound get() = endExclusive
override fun contains(value: T) = value > startExclusive && value < endExclusive
override fun isEmpty() = endExclusive <= startExclusive
override fun toString() = "($startExclusive..$endExclusive)"
}