package o; import com.huawei.hms.framework.common.ContainerUtils; import java.util.Iterator; import java.util.Map; import java.util.WeakHashMap; /* loaded from: classes.dex */ public class hFr implements Iterable> { public Sts a; public WeakHashMap, Boolean> c = new WeakHashMap<>(); public int d = 0; public Sts e; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public interface saX { void a_(Sts sts); } protected Sts d(K k) { Sts sts = this.a; while (sts != null && !sts.a.equals(k)) { sts = sts.b; } return sts; } public V a(K k, V v) { Sts d = d(k); if (d != null) { return d.e; } c(k, v); return null; } /* JADX INFO: Access modifiers changed from: protected */ public final Sts c(K k, V v) { Sts sts = new Sts<>(k, v); this.d++; Sts sts2 = this.e; if (sts2 == null) { this.a = sts; this.e = sts; return sts; } sts2.b = sts; sts.c = this.e; this.e = sts; return sts; } public V b(K k) { Sts d = d(k); if (d == null) { return null; } this.d--; if (!this.c.isEmpty()) { Iterator> it = this.c.keySet().iterator(); while (it.hasNext()) { it.next().a_(d); } } if (d.c != null) { d.c.b = d.b; } else { this.a = d.b; } if (d.b != null) { d.b.c = d.c; } else { this.e = d.c; } d.b = null; d.c = null; return d.e; } @Override // java.lang.Iterable public Iterator> iterator() { HBt hBt = new HBt(this.a, this.e); this.c.put(hBt, Boolean.FALSE); return hBt; } public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof hFr)) { return false; } hFr hfr = (hFr) obj; if (this.d != hfr.d) { return false; } Iterator> it = iterator(); Iterator> it2 = hfr.iterator(); while (it.hasNext() && it2.hasNext()) { Map.Entry next = it.next(); Map.Entry next2 = it2.next(); if ((next == null && next2 != null) || (next != null && !next.equals(next2))) { return false; } } return (it.hasNext() || it2.hasNext()) ? false : true; } public int hashCode() { Iterator> it = iterator(); int i = 0; while (it.hasNext()) { i += it.next().hashCode(); } return i; } public String toString() { StringBuilder sb = new StringBuilder("["); Iterator> it = iterator(); while (it.hasNext()) { sb.append(it.next().toString()); if (it.hasNext()) { sb.append(", "); } } sb.append("]"); return sb.toString(); } /* loaded from: classes.dex */ static abstract class RVV implements Iterator>, saX { private Sts a; private Sts e; abstract Sts b(Sts sts); abstract Sts c(Sts sts); @Override // java.util.Iterator public /* synthetic */ Object next() { Sts sts = this.e; Sts sts2 = this.a; this.e = (sts == sts2 || sts2 == null) ? null : b(sts); return sts; } RVV(Sts sts, Sts sts2) { this.a = sts2; this.e = sts; } @Override // o.hFr.saX public final void a_(Sts sts) { Sts sts2 = null; if (this.a == sts && sts == this.e) { this.e = null; this.a = null; } Sts sts3 = this.a; if (sts3 == sts) { this.a = c(sts3); } Sts sts4 = this.e; if (sts4 == sts) { Sts sts5 = this.a; if (sts4 != sts5 && sts5 != null) { sts2 = b(sts4); } this.e = sts2; } } @Override // java.util.Iterator public boolean hasNext() { return this.e != null; } } /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public static class HBt extends RVV { HBt(Sts sts, Sts sts2) { super(sts, sts2); } @Override // o.hFr.RVV final Sts b(Sts sts) { return sts.b; } @Override // o.hFr.RVV final Sts c(Sts sts) { return sts.c; } } /* loaded from: classes.dex */ public static class LWm extends RVV { public LWm(Sts sts, Sts sts2) { super(sts, sts2); } @Override // o.hFr.RVV final Sts b(Sts sts) { return sts.c; } @Override // o.hFr.RVV final Sts c(Sts sts) { return sts.b; } } /* loaded from: classes.dex */ public class IeS implements Iterator>, saX { private boolean b = true; final hFr c; private Sts d; @Override // java.util.Iterator public final /* bridge */ /* synthetic */ Object next() { if (this.b) { this.b = false; this.d = this.c.a; } else { Sts sts = this.d; this.d = sts != null ? sts.b : null; } return this.d; } public IeS(hFr hfr) { this.c = hfr; } @Override // o.hFr.saX public final void a_(Sts sts) { Sts sts2 = this.d; if (sts == sts2) { Sts sts3 = sts2.c; this.d = sts3; this.b = sts3 == null; } } @Override // java.util.Iterator public final boolean hasNext() { if (this.b) { return this.c.a != null; } Sts sts = this.d; return (sts == null || sts.b == null) ? false : true; } } /* loaded from: classes.dex */ public static class Sts implements Map.Entry { final K a; Sts b; public Sts c; final V e; Sts(K k, V v) { this.a = k; this.e = v; } @Override // java.util.Map.Entry public final V setValue(V v) { throw new UnsupportedOperationException("An entry modification is not supported"); } public final String toString() { StringBuilder sb = new StringBuilder(); sb.append(this.a); sb.append(ContainerUtils.KEY_VALUE_DELIMITER); sb.append(this.e); return sb.toString(); } @Override // java.util.Map.Entry public final boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Sts)) { return false; } Sts sts = (Sts) obj; return this.a.equals(sts.a) && this.e.equals(sts.e); } @Override // java.util.Map.Entry public final int hashCode() { return this.a.hashCode() ^ this.e.hashCode(); } @Override // java.util.Map.Entry public final V getValue() { return this.e; } @Override // java.util.Map.Entry public final K getKey() { return this.a; } } }