com.ancientlightstudios.quarkus.kotlin.openapi.utils.CollectionExtensions.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-kotlin-openapi-maven-plugin Show documentation
Show all versions of quarkus-kotlin-openapi-maven-plugin Show documentation
A Maven plugin to use the OpenAPI generator.
package com.ancientlightstudios.quarkus.kotlin.openapi.utils
data class LoopStatus(val index: Int, val first: Boolean, val last: Boolean)
inline fun Collection.forEachWithStats(action: (status: LoopStatus, T) -> Unit) {
val lastIndex = size - 1
this.forEachIndexed { index, item -> action(LoopStatus(index, index == 0, index == lastIndex), item) }
}
inline fun Array.forEachWithStats(action: (status: LoopStatus, T) -> Unit) {
val lastIndex = size - 1
this.forEachIndexed { index, item -> action(LoopStatus(index, index == 0, index == lastIndex), item) }
}