package androidx.coordinatorlayout.widget; import androidx.collection.g; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import y.e; import y.f; /* loaded from: classes.dex */ public final class b { /* renamed from: a, reason: collision with root package name */ private final e f1386a = new f(10); /* renamed from: b, reason: collision with root package name */ private final g f1387b = new g(); /* renamed from: c, reason: collision with root package name */ private final ArrayList f1388c = new ArrayList(); /* renamed from: d, reason: collision with root package name */ private final HashSet f1389d = new HashSet(); private void e(Object obj, ArrayList arrayList, HashSet hashSet) { if (arrayList.contains(obj)) { return; } if (hashSet.contains(obj)) { throw new RuntimeException("This graph contains cyclic dependencies"); } hashSet.add(obj); ArrayList arrayList2 = (ArrayList) this.f1387b.get(obj); if (arrayList2 != null) { int size = arrayList2.size(); for (int i10 = 0; i10 < size; i10++) { e(arrayList2.get(i10), arrayList, hashSet); } } hashSet.remove(obj); arrayList.add(obj); } private ArrayList f() { ArrayList arrayList = (ArrayList) this.f1386a.b(); return arrayList == null ? new ArrayList() : arrayList; } private void j(ArrayList arrayList) { arrayList.clear(); this.f1386a.a(arrayList); } public void a(Object obj, Object obj2) { if (!this.f1387b.containsKey(obj) || !this.f1387b.containsKey(obj2)) { throw new IllegalArgumentException("All nodes must be present in the graph before being added as an edge"); } ArrayList arrayList = (ArrayList) this.f1387b.get(obj); if (arrayList == null) { arrayList = f(); this.f1387b.put(obj, arrayList); } arrayList.add(obj2); } public void b(Object obj) { if (this.f1387b.containsKey(obj)) { return; } this.f1387b.put(obj, null); } public void c() { int size = this.f1387b.size(); for (int i10 = 0; i10 < size; i10++) { ArrayList arrayList = (ArrayList) this.f1387b.m(i10); if (arrayList != null) { j(arrayList); } } this.f1387b.clear(); } public boolean d(Object obj) { return this.f1387b.containsKey(obj); } public List g(Object obj) { int size = this.f1387b.size(); ArrayList arrayList = null; for (int i10 = 0; i10 < size; i10++) { ArrayList arrayList2 = (ArrayList) this.f1387b.m(i10); if (arrayList2 != null && arrayList2.contains(obj)) { if (arrayList == null) { arrayList = new ArrayList(); } arrayList.add(this.f1387b.i(i10)); } } return arrayList; } public ArrayList h() { this.f1388c.clear(); this.f1389d.clear(); int size = this.f1387b.size(); for (int i10 = 0; i10 < size; i10++) { e(this.f1387b.i(i10), this.f1388c, this.f1389d); } return this.f1388c; } public boolean i(Object obj) { int size = this.f1387b.size(); for (int i10 = 0; i10 < size; i10++) { ArrayList arrayList = (ArrayList) this.f1387b.m(i10); if (arrayList != null && arrayList.contains(obj)) { return true; } } return false; } }