How i missed this i have no idea
This commit is contained in:
parent
16f5f4c9c9
commit
6291cecb7e
@ -22,7 +22,7 @@ abstract class AbstractHistoryGraph<V : Any>(
|
|||||||
/**
|
/**
|
||||||
* Limit on how many graph values to store
|
* Limit on how many graph values to store
|
||||||
*/
|
*/
|
||||||
val width: Int = 100,
|
val width: Int,
|
||||||
) : Iterable<V>, INBTSerializable<CompoundTag>, ISynchable {
|
) : Iterable<V>, INBTSerializable<CompoundTag>, ISynchable {
|
||||||
constructor(ticks: Int) : this(1, ticks)
|
constructor(ticks: Int) : this(1, ticks)
|
||||||
|
|
||||||
@ -36,8 +36,27 @@ abstract class AbstractHistoryGraph<V : Any>(
|
|||||||
|
|
||||||
protected abstract fun calculateAverage(input: List<V>): V
|
protected abstract fun calculateAverage(input: List<V>): V
|
||||||
protected abstract fun sum(a: V, b: V): V
|
protected abstract fun sum(a: V, b: V): V
|
||||||
|
protected abstract fun sum(input: List<V>): V
|
||||||
protected abstract fun identity(): V
|
protected abstract fun identity(): V
|
||||||
|
|
||||||
|
fun calculateAverage(width: Int = this.width): V {
|
||||||
|
require(width >= 0) { "Invalid time frame: $width" }
|
||||||
|
|
||||||
|
if (width == 0 || this.values.isEmpty())
|
||||||
|
return identity()
|
||||||
|
|
||||||
|
return calculateAverage(this.values.subList(0, width.coerceAtMost(this.values.size)))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun calculateSum(width: Int = this.width): V {
|
||||||
|
require(width >= 0) { "Invalid time frame: $width" }
|
||||||
|
|
||||||
|
if (width == 0 || this.values.isEmpty())
|
||||||
|
return identity()
|
||||||
|
|
||||||
|
return sum(this.values.subList(0, width.coerceAtMost(this.values.size)))
|
||||||
|
}
|
||||||
|
|
||||||
abstract val codec: Codec<V>
|
abstract val codec: Codec<V>
|
||||||
abstract val streamCodec: MatteryStreamCodec<RegistryFriendlyByteBuf, V>
|
abstract val streamCodec: MatteryStreamCodec<RegistryFriendlyByteBuf, V>
|
||||||
|
|
||||||
@ -48,7 +67,7 @@ abstract class AbstractHistoryGraph<V : Any>(
|
|||||||
remotes.add(this)
|
remotes.add(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var shouldFullyNetwork = false
|
private var shouldFullyNetwork = true
|
||||||
private val networkValues = ArrayList<V>()
|
private val networkValues = ArrayList<V>()
|
||||||
|
|
||||||
override fun write(stream: RegistryFriendlyByteBuf) {
|
override fun write(stream: RegistryFriendlyByteBuf) {
|
||||||
|
Loading…
Reference in New Issue
Block a user