feat: Add macro wheels

This commit is contained in:
Linnea Gräf
2025-06-17 20:59:45 +02:00
parent 775933d516
commit 4b9e966ca7
24 changed files with 753 additions and 147 deletions

View File

@@ -0,0 +1,40 @@
package moe.nea.firmament.util.collections
import kotlin.math.floor
val ClosedFloatingPointRange<Float>.centre get() = (endInclusive + start) / 2
fun ClosedFloatingPointRange<Float>.nonNegligibleSubSectionsAlignedWith(
interval: Float
): Iterable<Float> {
require(interval.isFinite())
val range = this
return object : Iterable<Float> {
override fun iterator(): Iterator<Float> {
return object : FloatIterator() {
var polledValue: Float = range.start
var lastValue: Float = polledValue
override fun nextFloat(): Float {
if (!hasNext()) throw NoSuchElementException()
lastValue = polledValue
polledValue = Float.NaN
return lastValue
}
override fun hasNext(): Boolean {
if (!polledValue.isNaN()) {
return true
}
if (lastValue == range.endInclusive)
return false
polledValue = (floor(lastValue / interval) + 1) * interval
if (polledValue > range.endInclusive) {
polledValue = range.endInclusive
}
return true
}
}
}
}
}