Remove enum.next/prev
This commit is contained in:
parent
46eebd236a
commit
88d47ef4d5
@ -155,38 +155,6 @@ inline var Entity.position: Vec3
|
||||
get() = position()
|
||||
set(value) { setPos(value) }
|
||||
|
||||
inline val <reified T : Enum<T>> T.next: T get() {
|
||||
val values = enumValues<T>()
|
||||
val next = (ordinal + 1) % values.size
|
||||
return values[next]
|
||||
}
|
||||
|
||||
inline val <reified T : Enum<T>> T.prev: T get() {
|
||||
val values = enumValues<T>()
|
||||
var next = ordinal - 1
|
||||
|
||||
if (next < 0) {
|
||||
next = values.size - 1
|
||||
}
|
||||
|
||||
return values[next]
|
||||
}
|
||||
|
||||
fun <T : Enum<T>> T.next(values: Array<out T>): T {
|
||||
val next = (ordinal + 1) % values.size
|
||||
return values[next]
|
||||
}
|
||||
|
||||
fun <T : Enum<T>> T.prev(values: Array<out T>): T {
|
||||
var next = ordinal - 1
|
||||
|
||||
if (next < 0) {
|
||||
next = values.size - 1
|
||||
}
|
||||
|
||||
return values[next]
|
||||
}
|
||||
|
||||
inline fun <T : Any> immutableList(size: Int, initializer: (index: Int) -> T): ImmutableList<T> {
|
||||
require(size >= 0) { "Invalid list size $size" }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user