All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nield.kotlinstatistics.range.ClosedOpenRange.kt Maven / Gradle / Ivy

There is a newer version: 1.2.1
Show newest version
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)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy