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

commonMain.TypeOperations.kt Maven / Gradle / Ivy

package io.github.whathecode.kotlinx.interval


/**
 * Provides generic access to the predefined set of type operators of type [T].
 */
interface TypeOperations>
{
    /**
     * When this value is added to any value x, it yields x. I.e. commonly "zero".
     */
    val additiveIdentity: T

    /**
     * The minimum value an instance of [T] can have.
     */
    val minValue: T

    /**
     * The maximum value an instance of [T] can have.
     */
    val maxValue: T

    /**
     * If values of [T] are evenly spaced, the distance between each subsequent value of [T];
     * null otherwise, e.g., if values of [T] are dense.
     */
    val spacing: T?

    /**
     * The binary operation `a + b`, not safeguarded against overflows.
     * The resulting type is cast back to type [T].
     */
    fun unsafeAdd( a: T, b: T ): T

    /**
     * The binary operation `a - b`, not safeguarded against overflows.
     * The resulting type is cast back to type [T].
     */
    fun unsafeSubtract( a: T, b: T ): T
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy