package kotlinx.coroutines.internal;

import java.util.Objects;

/* JADX INFO: compiled from: ArrayQueue.kt */
/* JADX INFO: loaded from: classes.dex */
public class a<T> {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    private Object[] f5173a = new Object[16];

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    private int f5174b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    private int f5175c;

    private final void b() {
        Object[] objArr = this.f5173a;
        int length = objArr.length;
        Object[] objArr2 = new Object[length << 1];
        l1.d.c(objArr, objArr2, 0, this.f5174b, 0, 10, null);
        Object[] objArr3 = this.f5173a;
        int length2 = objArr3.length;
        int i3 = this.f5174b;
        l1.d.c(objArr3, objArr2, length2 - i3, 0, i3, 4, null);
        this.f5173a = objArr2;
        this.f5174b = 0;
        this.f5175c = length;
    }

    public final void a(T t2) {
        Object[] objArr = this.f5173a;
        int i3 = this.f5175c;
        objArr[i3] = t2;
        int length = (objArr.length - 1) & (i3 + 1);
        this.f5175c = length;
        if (length == this.f5174b) {
            b();
        }
    }

    public final boolean c() {
        return this.f5174b == this.f5175c;
    }

    public final T d() {
        int i3 = this.f5174b;
        if (i3 == this.f5175c) {
            return null;
        }
        Object[] objArr = this.f5173a;
        T t2 = (T) objArr[i3];
        objArr[i3] = null;
        this.f5174b = (i3 + 1) & (objArr.length - 1);
        Objects.requireNonNull(t2, "null cannot be cast to non-null type T of kotlinx.coroutines.internal.ArrayQueue");
        return t2;
    }
}
