package androidx.compose.ui.platform;

import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;

/* loaded from: classes.dex */
public final class g3 {

    /* renamed from: a, reason: collision with root package name */
    private final a1.b f2440a = new a1.b(new Reference[16], 0);

    /* renamed from: b, reason: collision with root package name */
    private final ReferenceQueue f2441b = new ReferenceQueue();

    private final void a() {
        Reference poll;
        do {
            poll = this.f2441b.poll();
            if (poll != null) {
                this.f2440a.x(poll);
            }
        } while (poll != null);
    }

    public final Object b() {
        a();
        while (this.f2440a.t()) {
            Object obj = ((Reference) this.f2440a.z(r0.q() - 1)).get();
            if (obj != null) {
                return obj;
            }
        }
        return null;
    }

    public final void c(Object obj) {
        a();
        this.f2440a.c(new WeakReference(obj, this.f2441b));
    }
}
