mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-17 00:56:07 +09:00
fixed a NaN bug caused by a zero-width/height hitbox
Also inventory is widened to 10x7 of prev 9x7
This commit is contained in:
@@ -29,13 +29,6 @@ class CircularArray<T>(val size: Int) {
|
||||
}
|
||||
|
||||
inline fun forEach(action: (T) -> Unit) {
|
||||
/*if (tail >= head) { // queue not full
|
||||
(head..tail - 1).map { buffer[it] }.forEach { action(it) }
|
||||
}
|
||||
else { // queue full
|
||||
(0..size - 1).map { buffer[(it + head) % size] }.forEach { action(it) }
|
||||
}*/
|
||||
|
||||
// has slightly better iteration performance than lambda
|
||||
if (tail >= head) {
|
||||
for (i in head..tail - 1)
|
||||
@@ -47,6 +40,22 @@ class CircularArray<T>(val size: Int) {
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME not working as intended
|
||||
inline fun <R> fold(initial: R, operation: (R, T) -> R): R {
|
||||
var accumulator = initial
|
||||
//for (element in buffer) accumulator = operation(accumulator, element)
|
||||
if (tail >= head) {
|
||||
for (i in head..tail - 1)
|
||||
operation(accumulator, buffer[i])
|
||||
}
|
||||
else {
|
||||
for (i in 0..size - 1)
|
||||
operation(accumulator, buffer[(i + head) % size])
|
||||
}
|
||||
|
||||
return accumulator
|
||||
}
|
||||
|
||||
inline fun forEachConcurrent(action: (T) -> Unit) {
|
||||
TODO()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user