package d.g.b;

import d.e.h;
import d.h.i.d;
import java.util.ArrayList;
import java.util.HashSet;

/* JADX INFO: loaded from: classes.dex */
public final class a<T> {
    public final d<ArrayList<T>> a = new d<>(10);

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final h<T, ArrayList<T>> f2560b = new h<>();

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final ArrayList<T> f2561c = new ArrayList<>();

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final HashSet<T> f2562d = new HashSet<>();

    public void a(T t2) {
        if (this.f2560b.f(t2) >= 0) {
            return;
        }
        this.f2560b.put(t2, null);
    }

    public final void b(T t2, ArrayList<T> arrayList, HashSet<T> hashSet) {
        if (arrayList.contains(t2)) {
            return;
        }
        if (hashSet.contains(t2)) {
            throw new RuntimeException("This graph contains cyclic dependencies");
        }
        hashSet.add(t2);
        ArrayList<T> orDefault = this.f2560b.getOrDefault(t2, null);
        if (orDefault != null) {
            int size = orDefault.size();
            for (int i2 = 0; i2 < size; i2++) {
                b(orDefault.get(i2), arrayList, hashSet);
            }
        }
        hashSet.remove(t2);
        arrayList.add(t2);
    }
}
