/*
 * Decompiled with CFR 0.152.
 */
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

public final class ek {
    private long[] b;
    public int a;

    public ek(int n) {
        this.b = new long[n];
    }

    public ek() {
        this.b = new long[16];
    }

    private void c(int n) {
        if (n > this.b.length) {
            int n2 = this.b.length + 16;
            if (n2 >= n) {
                n = n2;
            }
            long[] lArray = new long[n];
            System.arraycopy(this.b, 0, lArray, 0, this.a);
            this.b = lArray;
        }
    }

    public final byte[] c() {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(this.a * 8);
        DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream);
        for (int i = 0; i < this.a; ++i) {
            dataOutputStream.writeLong(this.b[i]);
        }
        return byteArrayOutputStream.toByteArray();
    }

    public final String toString() {
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append('[');
        for (int i = 0; i < this.a; ++i) {
            stringBuffer.append(this.b[i]);
            if (i >= this.a - 1) continue;
            stringBuffer.append(", ");
        }
        stringBuffer.append(']');
        return stringBuffer.toString();
    }

    public static ek a(byte[] byArray) {
        if (byArray.length % 8 == 0) {
            int n = byArray.length / 8;
            ek ek2 = new ek(n);
            DataInputStream dataInputStream = new DataInputStream(new ByteArrayInputStream(byArray));
            for (int i = 0; i < n; ++i) {
                ek2.a(dataInputStream.readLong());
            }
            return ek2;
        }
        throw new IOException("Buffer length not divisible by 8.");
    }

    public final void a(long l, int n) {
        if (n < this.a) {
            this.b[n] = l;
            return;
        }
        throw new ArrayIndexOutOfBoundsException();
    }

    public final long a(int n) {
        if (n < this.a) {
            return this.b[n];
        }
        throw new ArrayIndexOutOfBoundsException();
    }

    public final void b(int n) {
        if (n >= 0) {
            this.c(n);
            for (int i = this.a; i < n; ++i) {
                this.b[i] = 0L;
            }
            this.a = n;
            return;
        }
        throw new ArrayIndexOutOfBoundsException();
    }

    public final boolean c(long l) {
        for (int i = 0; i < this.a; ++i) {
            if (this.b[i] != l) {
                continue;
            }
            --this.a;
            System.arraycopy(this.b, i + 1, this.b, i, this.a - i);
            return true;
        }
        return false;
    }

    public final boolean b(long l) {
        block2: {
            for (int i = this.a - 1; i >= 0; --i) {
                if (this.b[i] != l) {
                    continue;
                }
                break block2;
            }
            return false;
        }
        return true;
    }

    public final boolean a() {
        return this.a == 0;
    }

    public final void a(long l) {
        this.c(this.a + 1);
        this.b[this.a++] = l;
    }
}

