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

oc.runtime-components.0.9.0.source-code.CollectionOverflowChecks.kt Maven / Gradle / Ivy

The newest version!
@file:OptIn(ExperimentalTypeInference::class)
@file:Suppress("NOTHING_TO_INLINE", "unused")

package com.sschr15.aoc.annotations

import kotlin.experimental.ExperimentalTypeInference

@JvmName("sumOfBytes")
inline fun sum(items: Iterable): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, item.toInt())
    }
    return sum
}

@JvmName("sumOfBytes")
inline fun sum(items: Sequence): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, item.toInt())
    }
    return sum
}

@JvmName("sumOfBytes")
inline fun sum(items: Array): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, item.toInt())
    }
    return sum
}

inline fun sum(items: ByteArray): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, item.toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumOfBytesToBytes")
inline fun sumOf(items: ByteArray, transform: (Byte) -> Byte): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumOfBytesToShorts")
inline fun sumOf(items: ByteArray, transform: (Byte) -> Short): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumOfBytesToInts")
inline fun sumOf(items: ByteArray, transform: (Byte) -> Int): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumOfBytesToLongs")
inline fun sumOf(items: ByteArray, transform: (Byte) -> Long): Long {
    var sum = 0L
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toLong())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumOfCharsToBytes")
inline fun sumOf(items: CharArray, transform: (Char) -> Byte): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@JvmName("sumOfShorts")
inline fun sum(items: Iterable): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, item.toInt())
    }
    return sum
}

@JvmName("sumOfShorts")
inline fun sum(items: Sequence): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, item.toInt())
    }
    return sum
}

@JvmName("sumOfShorts")
inline fun sum(items: Array): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, item.toInt())
    }
    return sum
}

inline fun sum(items: ShortArray): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, item.toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumOfShortsToBytes")
inline fun sumOf(items: ShortArray, transform: (Short) -> Byte): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumOfShortsToShorts")
inline fun sumOf(items: ShortArray, transform: (Short) -> Short): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumOfShortsToInts")
inline fun sumOf(items: ShortArray, transform: (Short) -> Int): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumOfShortsToLongs")
inline fun sumOf(items: ShortArray, transform: (Short) -> Long): Long {
    var sum = 0L
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toLong())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumOfCharsToShorts")
inline fun sumOf(items: CharArray, transform: (Char) -> Short): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@JvmName("sumOfInts")
inline fun sum(items: Iterable): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, item.toInt())
    }
    return sum
}

@JvmName("sumOfInts")
inline fun sum(items: Sequence): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, item.toInt())
    }
    return sum
}

@JvmName("sumOfInts")
inline fun sum(items: Array): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, item.toInt())
    }
    return sum
}

inline fun sum(items: IntArray): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, item.toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumOfIntsToBytes")
inline fun sumOf(items: IntArray, transform: (Int) -> Byte): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumOfIntsToShorts")
inline fun sumOf(items: IntArray, transform: (Int) -> Short): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumOfIntsToInts")
inline fun sumOf(items: IntArray, transform: (Int) -> Int): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumOfIntsToLongs")
inline fun sumOf(items: IntArray, transform: (Int) -> Long): Long {
    var sum = 0L
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toLong())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumOfCharsToInts")
inline fun sumOf(items: CharArray, transform: (Char) -> Int): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@JvmName("sumOfLongs")
inline fun sum(items: Iterable): Long {
    var sum = 0L
    for (item in items) {
        sum = Math.addExact(sum, item.toLong())
    }
    return sum
}

@JvmName("sumOfLongs")
inline fun sum(items: Sequence): Long {
    var sum = 0L
    for (item in items) {
        sum = Math.addExact(sum, item.toLong())
    }
    return sum
}

@JvmName("sumOfLongs")
inline fun sum(items: Array): Long {
    var sum = 0L
    for (item in items) {
        sum = Math.addExact(sum, item.toLong())
    }
    return sum
}

inline fun sum(items: LongArray): Long {
    var sum = 0L
    for (item in items) {
        sum = Math.addExact(sum, item.toLong())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumOfLongsToBytes")
inline fun sumOf(items: LongArray, transform: (Long) -> Byte): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumOfLongsToShorts")
inline fun sumOf(items: LongArray, transform: (Long) -> Short): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumOfLongsToInts")
inline fun sumOf(items: LongArray, transform: (Long) -> Int): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumOfLongsToLongs")
inline fun sumOf(items: LongArray, transform: (Long) -> Long): Long {
    var sum = 0L
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toLong())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumOfCharsToLongs")
inline fun sumOf(items: CharArray, transform: (Char) -> Long): Long {
    var sum = 0L
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toLong())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumToBytes")
inline fun  sumOf(items: Iterable, transform: (T) -> Byte): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumToShorts")
inline fun  sumOf(items: Iterable, transform: (T) -> Short): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumToInts")
inline fun  sumOf(items: Iterable, transform: (T) -> Int): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumToLongs")
inline fun  sumOf(items: Iterable, transform: (T) -> Long): Long {
    var sum = 0L
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toLong())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumToBytes")
inline fun  sumOf(items: Sequence, transform: (T) -> Byte): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumToShorts")
inline fun  sumOf(items: Sequence, transform: (T) -> Short): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumToInts")
inline fun  sumOf(items: Sequence, transform: (T) -> Int): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumToLongs")
inline fun  sumOf(items: Sequence, transform: (T) -> Long): Long {
    var sum = 0L
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toLong())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumToBytes")
inline fun  sumOf(items: Array, transform: (T) -> Byte): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumToShorts")
inline fun  sumOf(items: Array, transform: (T) -> Short): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumToInts")
inline fun  sumOf(items: Array, transform: (T) -> Int): Int {
    var sum = 0
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toInt())
    }
    return sum
}

@OverloadResolutionByLambdaReturnType
@JvmName("sumToLongs")
inline fun  sumOf(items: Array, transform: (T) -> Long): Long {
    var sum = 0L
    for (item in items) {
        sum = Math.addExact(sum, transform(item).toLong())
    }
    return sum
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy