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

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

There is a newer version: 1.2.1
Show newest version
package org.nield.kotlinstatistics.range

class OpenClosedRange>(val startExclusive: T, val endInclusive: T): Range {

    init {
        if (startExclusive > endInclusive) throw InvalidRangeException("($startExclusive..$endInclusive] is an invalid OpenClosedRange!")
    }

    override val lowerBound get() = startExclusive

    override val upperBound get() = endInclusive

    override fun contains(value: T) = value > startExclusive && value <= endInclusive

    override fun isEmpty() = endInclusive == startExclusive

    override fun toString() = "($startExclusive..$endInclusive]"
}






© 2015 - 2024 Weber Informatics LLC | Privacy Policy