mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-12 06:41:51 +09:00
disposable UI; loading screen mockup (i heard like loading screen -- sonic 06)
This commit is contained in:
@@ -1,16 +1,20 @@
|
||||
package net.torvald.dataclass
|
||||
|
||||
import java.util.*
|
||||
import java.util.function.Consumer
|
||||
|
||||
/**
|
||||
* Simple ArrayList wrapper that acts as history keeper. You can append any data but cannot delete.
|
||||
*
|
||||
* Created by minjaesong on 16-07-13.
|
||||
*/
|
||||
class HistoryArray<T>(val historyMax: Int) {
|
||||
class HistoryArray<T>(val size: Int) {
|
||||
|
||||
val history = ArrayList<T?>(Math.min(historyMax, 256)) // 256: arbitrary set upper bound
|
||||
val history = ArrayList<T?>(Math.min(size, 256)) // 256: arbitrary set upper bound
|
||||
|
||||
val lastIndex = size - 1
|
||||
|
||||
val elemCount: Int
|
||||
get() = history.size
|
||||
|
||||
fun add(value: T) {
|
||||
if (history.size == 0) {
|
||||
@@ -20,11 +24,11 @@ class HistoryArray<T>(val historyMax: Int) {
|
||||
// push existing values to an index
|
||||
else {
|
||||
for (i in history.size - 1 downTo 0) {
|
||||
// if history.size is smaller than historyMax, make room by appending
|
||||
if (i == history.size - 1 && i < historyMax - 1)
|
||||
// if history.size is smaller than 'size', make room by appending
|
||||
if (i == history.size - 1 && i < size - 1)
|
||||
history.add(history[i])
|
||||
// actually move if we have some room
|
||||
else if (i < historyMax - 1)
|
||||
else if (i < size - 1)
|
||||
history[i + 1] = history[i]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user