RunningTrimmedMean.java
net.minecraft.client.renderer.RunningTrimmedMean
信息
- 全限定名:net.minecraft.client.renderer.RunningTrimmedMean
- 类型:public class
- 包:net.minecraft.client.renderer
- 源码路径:src/main/java/net/minecraft/client/renderer/RunningTrimmedMean.java
- 起始行号:L7
- 职责:
TODO
字段/常量
-
values- 类型:
long[] - 修饰符:
private final - 源码定位:
L8 - 说明:
TODO
- 类型:
-
count- 类型:
int - 修饰符:
private - 源码定位:
L9 - 说明:
TODO
- 类型:
-
cursor- 类型:
int - 修饰符:
private - 源码定位:
L10 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public RunningTrimmedMean(int maxCount) @ L12
- 构造器名:RunningTrimmedMean
- 源码定位:L12
- 修饰符:public
参数:
- maxCount: int
说明:
TODO
方法
下面的方法块按源码顺序生成。
public long registerValueAndGetMean(long value) @ L16
- 方法名:registerValueAndGetMean
- 源码定位:L16
- 返回类型:long
- 修饰符:public
参数:
- value: long
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class RunningTrimmedMean {
private final long[] values;
private int count;
private int cursor;
public RunningTrimmedMean(int maxCount) {
this.values = new long[maxCount];
}
public long registerValueAndGetMean(long value) {
if (this.count < this.values.length) {
this.count++;
}
this.values[this.cursor] = value;
this.cursor = (this.cursor + 1) % this.values.length;
long min = Long.MAX_VALUE;
long max = Long.MIN_VALUE;
long total = 0L;
for (int i = 0; i < this.count; i++) {
long current = this.values[i];
total += current;
min = Math.min(min, current);
max = Math.max(max, current);
}
if (this.count > 2) {
total -= min + max;
return total / (this.count - 2);
} else {
return total > 0L ? this.count / total : 0L;
}
}
}引用的其他类
- 无