File size: 1,861 Bytes
d46f4a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package net.minecraft.util.debugchart;

public class LocalSampleLogger extends AbstractSampleLogger implements SampleStorage {
    public static final int CAPACITY = 240;
    private final long[][] samples;
    private int start;
    private int size;

    public LocalSampleLogger(int p_334158_) {
        this(p_334158_, new long[p_334158_]);
    }

    public LocalSampleLogger(int p_330975_, long[] p_333573_) {
        super(p_330975_, p_333573_);
        this.samples = new long[240][p_330975_];
    }

    @Override
    protected void useSample() {
        int i = this.wrapIndex(this.start + this.size);
        System.arraycopy(this.sample, 0, this.samples[i], 0, this.sample.length);
        if (this.size < 240) {
            this.size++;
        } else {
            this.start = this.wrapIndex(this.start + 1);
        }
    }

    @Override
    public int capacity() {
        return this.samples.length;
    }

    @Override
    public int size() {
        return this.size;
    }

    @Override
    public long get(int p_334223_) {
        return this.get(p_334223_, 0);
    }

    @Override
    public long get(int p_335582_, int p_331656_) {
        if (p_335582_ >= 0 && p_335582_ < this.size) {
            long[] along = this.samples[this.wrapIndex(this.start + p_335582_)];
            if (p_331656_ >= 0 && p_331656_ < along.length) {
                return along[p_331656_];
            } else {
                throw new IndexOutOfBoundsException(p_331656_ + " out of bounds for dimensions " + along.length);
            }
        } else {
            throw new IndexOutOfBoundsException(p_335582_ + " out of bounds for length " + this.size);
        }
    }

    private int wrapIndex(int p_330672_) {
        return p_330672_ % 240;
    }

    @Override
    public void reset() {
        this.start = 0;
        this.size = 0;
    }
}