package com.applovin.impl; import com.applovin.exoplayer2.common.base.Preconditions; import com.applovin.impl.h; import com.applovin.impl.vc; import java.io.Serializable; import java.util.AbstractCollection; import java.util.Collection; import java.util.Comparator; import java.util.ConcurrentModificationException; import java.util.Iterator; import java.util.List; import java.util.ListIterator; import java.util.Map; import java.util.NavigableMap; import java.util.NavigableSet; import java.util.RandomAccess; import java.util.Set; import java.util.SortedMap; import java.util.SortedSet; /* loaded from: classes.dex */ abstract class f extends com.applovin.impl.h implements Serializable { private transient Map d; private transient int f; public abstract Collection a(Object obj, Collection collection); public abstract Collection c(Collection collection); @Override // com.applovin.impl.h public Collection d() { return new h.a(); } @Override // com.applovin.impl.h public Iterator f() { return new a(); } public abstract Collection g(); @Override // com.applovin.impl.uf public int size() { return this.f; } public static /* synthetic */ int b(f fVar) { int i2 = fVar.f; fVar.f = i2 + 1; return i2; } public static /* synthetic */ int c(f fVar) { int i2 = fVar.f; fVar.f = i2 - 1; return i2; } public f(Map map) { Preconditions.checkArgument(map.isEmpty()); this.d = map; } public static /* synthetic */ int b(f fVar, int i2) { int i3 = fVar.f - i2; fVar.f = i3; return i3; } @Override // com.applovin.impl.uf public boolean put(Object obj, Object obj2) { Collection collection = (Collection) this.d.get(obj); if (collection == null) { Collection b2 = b(obj); if (b2.add(obj2)) { this.f++; this.d.put(obj, b2); return true; } throw new AssertionError("New Collection violated the Collection spec"); } if (!collection.add(obj2)) { return false; } this.f++; return true; } public static /* synthetic */ int a(f fVar, int i2) { int i3 = fVar.f + i2; fVar.f = i3; return i3; } @Override // com.applovin.impl.uf public void clear() { Iterator it = this.d.values().iterator(); while (it.hasNext()) { ((Collection) it.next()).clear(); } this.d.clear(); this.f = 0; } public class j extends AbstractCollection { final Object a; Collection b; final j c; final Collection d; public j b() { return this.c; } public Collection c() { return this.b; } public Object d() { return this.a; } public j(Object obj, Collection collection, j jVar) { this.a = obj; this.b = collection; this.c = jVar; this.d = jVar == null ? null : jVar.c(); } public void e() { Collection collection; j jVar = this.c; if (jVar != null) { jVar.e(); if (this.c.c() != this.d) { throw new ConcurrentModificationException(); } } else { if (!this.b.isEmpty() || (collection = (Collection) f.this.d.get(this.a)) == null) { return; } this.b = collection; } } public void f() { j jVar = this.c; if (jVar != null) { jVar.f(); } else if (this.b.isEmpty()) { f.this.d.remove(this.a); } } public void a() { j jVar = this.c; if (jVar == null) { f.this.d.put(this.a, this.b); } else { jVar.a(); } } @Override // java.util.AbstractCollection, java.util.Collection public int size() { e(); return this.b.size(); } @Override // java.util.Collection public boolean equals(Object obj) { if (obj == this) { return true; } e(); return this.b.equals(obj); } @Override // java.util.Collection public int hashCode() { e(); return this.b.hashCode(); } @Override // java.util.AbstractCollection public String toString() { e(); return this.b.toString(); } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable public Iterator iterator() { e(); return new a(); } public class a implements Iterator { final Iterator a; final Collection b; public a() { Collection collection = j.this.b; this.b = collection; this.a = f.b(collection); } public void b() { j.this.e(); if (j.this.b != this.b) { throw new ConcurrentModificationException(); } } @Override // java.util.Iterator public boolean hasNext() { b(); return this.a.hasNext(); } @Override // java.util.Iterator public Object next() { b(); return this.a.next(); } @Override // java.util.Iterator public void remove() { this.a.remove(); f.c(f.this); j.this.f(); } public Iterator a() { b(); return this.a; } public a(Iterator it) { this.b = j.this.b; this.a = it; } } @Override // java.util.AbstractCollection, java.util.Collection public boolean add(Object obj) { e(); boolean isEmpty = this.b.isEmpty(); boolean add = this.b.add(obj); if (add) { f.b(f.this); if (isEmpty) { a(); } } return add; } @Override // java.util.AbstractCollection, java.util.Collection public boolean addAll(Collection collection) { if (collection.isEmpty()) { return false; } int size = size(); boolean addAll = this.b.addAll(collection); if (addAll) { f.a(f.this, this.b.size() - size); if (size == 0) { a(); } } return addAll; } @Override // java.util.AbstractCollection, java.util.Collection public boolean contains(Object obj) { e(); return this.b.contains(obj); } @Override // java.util.AbstractCollection, java.util.Collection public boolean containsAll(Collection collection) { e(); return this.b.containsAll(collection); } @Override // java.util.AbstractCollection, java.util.Collection public void clear() { int size = size(); if (size == 0) { return; } this.b.clear(); f.b(f.this, size); f(); } @Override // java.util.AbstractCollection, java.util.Collection public boolean remove(Object obj) { e(); boolean remove = this.b.remove(obj); if (remove) { f.c(f.this); f(); } return remove; } @Override // java.util.AbstractCollection, java.util.Collection public boolean removeAll(Collection collection) { if (collection.isEmpty()) { return false; } int size = size(); boolean removeAll = this.b.removeAll(collection); if (removeAll) { f.a(f.this, this.b.size() - size); f(); } return removeAll; } @Override // java.util.AbstractCollection, java.util.Collection public boolean retainAll(Collection collection) { Preconditions.checkNotNull(collection); int size = size(); boolean retainAll = this.b.retainAll(collection); if (retainAll) { f.a(f.this, this.b.size() - size); f(); } return retainAll; } } public Collection b(Object obj) { return g(); } public final List a(Object obj, List list, j jVar) { if (list instanceof RandomAccess) { return new g(obj, list, jVar); } return new k(obj, list, jVar); } public class k extends j implements List { public k(Object obj, List list, j jVar) { super(obj, list, jVar); } public List g() { return (List) c(); } @Override // java.util.List public boolean addAll(int i, Collection collection) { if (collection.isEmpty()) { return false; } int size = size(); boolean addAll = g().addAll(i, collection); if (addAll) { f.a(f.this, c().size() - size); if (size == 0) { a(); } } return addAll; } @Override // java.util.List public Object get(int i) { e(); return g().get(i); } @Override // java.util.List public Object set(int i, Object obj) { e(); return g().set(i, obj); } @Override // java.util.List public void add(int i, Object obj) { e(); boolean isEmpty = c().isEmpty(); g().add(i, obj); f.b(f.this); if (isEmpty) { a(); } } @Override // java.util.List public Object remove(int i) { e(); Object remove = g().remove(i); f.c(f.this); f(); return remove; } @Override // java.util.List public int indexOf(Object obj) { e(); return g().indexOf(obj); } @Override // java.util.List public int lastIndexOf(Object obj) { e(); return g().lastIndexOf(obj); } @Override // java.util.List public ListIterator listIterator() { e(); return new a(); } @Override // java.util.List public List subList(int i, int i2) { e(); return f.this.a(d(), g().subList(i, i2), b() == null ? this : b()); } public class a extends j.a implements ListIterator { public a() { super(); } private ListIterator c() { return (ListIterator) a(); } @Override // java.util.ListIterator public boolean hasPrevious() { return c().hasPrevious(); } @Override // java.util.ListIterator public Object previous() { return c().previous(); } @Override // java.util.ListIterator public int nextIndex() { return c().nextIndex(); } @Override // java.util.ListIterator public int previousIndex() { return c().previousIndex(); } @Override // java.util.ListIterator public void set(Object obj) { c().set(obj); } @Override // java.util.ListIterator public void add(Object obj) { boolean isEmpty = k.this.isEmpty(); c().add(obj); f.b(f.this); if (isEmpty) { k.this.a(); } } public a(int i) { super(k.this.g().listIterator(i)); } } @Override // java.util.List public ListIterator listIterator(int i) { e(); return new a(i); } } public class g extends k implements RandomAccess { public g(Object obj, List list, j jVar) { super(obj, list, jVar); } } public final Set i() { Map map = this.d; if (map instanceof NavigableMap) { return new C0020f((NavigableMap) this.d); } if (map instanceof SortedMap) { return new i((SortedMap) this.d); } return new d(this.d); } public class d extends vc.d { public d(Map map) { super(map); } public class a implements Iterator { Map.Entry a; final /* synthetic */ Iterator b; public a(Iterator it) { this.b = it; } @Override // java.util.Iterator public boolean hasNext() { return this.b.hasNext(); } @Override // java.util.Iterator public Object next() { Map.Entry entry = (Map.Entry) this.b.next(); this.a = entry; return entry.getKey(); } @Override // java.util.Iterator public void remove() { p3.a(this.a != null); Collection collection = (Collection) this.a.getValue(); this.b.remove(); f.b(f.this, collection.size()); collection.clear(); this.a = null; } } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set public Iterator iterator() { return new a(a().entrySet().iterator()); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean remove(Object obj) { Collection collection = (Collection) a().remove(obj); if (collection != null) { int size = collection.size(); collection.clear(); f.b(f.this, size); if (size > 0) { return true; } } return false; } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public void clear() { xb.a(iterator()); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean containsAll(Collection collection) { return a().keySet().containsAll(collection); } @Override // java.util.AbstractSet, java.util.Collection, java.util.Set public boolean equals(Object obj) { return this == obj || a().keySet().equals(obj); } @Override // java.util.AbstractSet, java.util.Collection, java.util.Set public int hashCode() { return a().keySet().hashCode(); } } /* JADX INFO: Access modifiers changed from: private */ public static Iterator b(Collection collection) { if (collection instanceof List) { return ((List) collection).listIterator(); } return collection.iterator(); } public class i extends d implements SortedSet { public SortedSet headSet(Object obj) { return f.this.new i(b().headMap(obj)); } public SortedSet subSet(Object obj, Object obj2) { return f.this.new i(b().subMap(obj, obj2)); } public SortedSet tailSet(Object obj) { return f.this.new i(b().tailMap(obj)); } public i(SortedMap sortedMap) { super(sortedMap); } public SortedMap b() { return (SortedMap) super.a(); } @Override // java.util.SortedSet public Comparator comparator() { return b().comparator(); } @Override // java.util.SortedSet public Object first() { return b().firstKey(); } @Override // java.util.SortedSet public Object last() { return b().lastKey(); } } /* renamed from: com.applovin.impl.f$f, reason: collision with other inner class name */ public class C0020f extends i implements NavigableSet { @Override // java.util.NavigableSet public NavigableSet descendingSet() { return f.this.new C0020f(b().descendingMap()); } @Override // java.util.NavigableSet public NavigableSet headSet(Object obj, boolean z) { return f.this.new C0020f(b().headMap(obj, z)); } @Override // java.util.NavigableSet public NavigableSet subSet(Object obj, boolean z, Object obj2, boolean z2) { return f.this.new C0020f(b().subMap(obj, z, obj2, z2)); } @Override // java.util.NavigableSet public NavigableSet tailSet(Object obj, boolean z) { return f.this.new C0020f(b().tailMap(obj, z)); } public C0020f(NavigableMap navigableMap) { super(navigableMap); } @Override // com.applovin.impl.f.i /* renamed from: c, reason: merged with bridge method [inline-methods] */ public NavigableMap b() { return (NavigableMap) super.b(); } @Override // java.util.NavigableSet public Object lower(Object obj) { return b().lowerKey(obj); } @Override // java.util.NavigableSet public Object floor(Object obj) { return b().floorKey(obj); } @Override // java.util.NavigableSet public Object ceiling(Object obj) { return b().ceilingKey(obj); } @Override // java.util.NavigableSet public Object higher(Object obj) { return b().higherKey(obj); } @Override // java.util.NavigableSet public Object pollFirst() { return xb.c(iterator()); } @Override // java.util.NavigableSet public Object pollLast() { return xb.c(descendingIterator()); } @Override // java.util.NavigableSet public Iterator descendingIterator() { return descendingSet().iterator(); } @Override // com.applovin.impl.f.i, java.util.SortedSet, java.util.NavigableSet /* renamed from: a, reason: merged with bridge method [inline-methods] */ public NavigableSet headSet(Object obj) { return headSet(obj, false); } @Override // com.applovin.impl.f.i, java.util.SortedSet, java.util.NavigableSet /* renamed from: b, reason: merged with bridge method [inline-methods] */ public NavigableSet tailSet(Object obj) { return tailSet(obj, true); } @Override // com.applovin.impl.f.i, java.util.SortedSet, java.util.NavigableSet /* renamed from: a, reason: merged with bridge method [inline-methods] */ public NavigableSet subSet(Object obj, Object obj2) { return subSet(obj, true, obj2, false); } } public abstract class c implements Iterator { final Iterator a; Object b = null; Collection c = null; Iterator d = xb.c(); public abstract Object a(Object obj, Object obj2); public c() { this.a = f.this.d.entrySet().iterator(); } @Override // java.util.Iterator public boolean hasNext() { return this.a.hasNext() || this.d.hasNext(); } @Override // java.util.Iterator public Object next() { if (!this.d.hasNext()) { Map.Entry entry = (Map.Entry) this.a.next(); this.b = entry.getKey(); Collection collection = (Collection) entry.getValue(); this.c = collection; this.d = collection.iterator(); } return a(this.b, this.d.next()); } @Override // java.util.Iterator public void remove() { this.d.remove(); if (this.c.isEmpty()) { this.a.remove(); } f.c(f.this); } } @Override // com.applovin.impl.h, com.applovin.impl.uf public Collection values() { return super.values(); } public class a extends c { @Override // com.applovin.impl.f.c public Object a(Object obj, Object obj2) { return obj2; } public a() { super(); } } /* JADX INFO: Access modifiers changed from: private */ public void c(Object obj) { Collection collection = (Collection) vc.d(this.d, obj); if (collection != null) { int size = collection.size(); collection.clear(); this.f -= size; } } public final Map h() { Map map = this.d; if (map instanceof NavigableMap) { return new e((NavigableMap) this.d); } if (map instanceof SortedMap) { return new h((SortedMap) this.d); } return new b(this.d); } public class b extends vc.f { final transient Map c; public b(Map map) { this.c = map; } @Override // java.util.AbstractMap, java.util.Map public boolean containsKey(Object obj) { return vc.b(this.c, obj); } @Override // java.util.AbstractMap, java.util.Map public Set keySet() { return f.this.e(); } @Override // java.util.AbstractMap, java.util.Map public int size() { return this.c.size(); } @Override // java.util.AbstractMap, java.util.Map public boolean equals(Object obj) { return this == obj || this.c.equals(obj); } @Override // java.util.AbstractMap, java.util.Map public int hashCode() { return this.c.hashCode(); } @Override // java.util.AbstractMap public String toString() { return this.c.toString(); } @Override // java.util.AbstractMap, java.util.Map public void clear() { if (this.c == f.this.d) { f.this.clear(); } else { xb.a((Iterator) new C0019b()); } } public Map.Entry a(Map.Entry entry) { Object key = entry.getKey(); return vc.a(key, f.this.a(key, (Collection) entry.getValue())); } @Override // com.applovin.impl.vc.f public Set a() { return new a(); } public class a extends vc.c { @Override // com.applovin.impl.vc.c public Map a() { return b.this; } @Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set public Iterator iterator() { return b.this.new C0019b(); } public a() { } @Override // com.applovin.impl.vc.c, java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean contains(Object obj) { return q3.a(b.this.c.entrySet(), obj); } @Override // java.util.AbstractCollection, java.util.Collection, java.util.Set public boolean remove(Object obj) { if (!contains(obj)) { return false; } f.this.c(((Map.Entry) obj).getKey()); return true; } } /* renamed from: com.applovin.impl.f$b$b, reason: collision with other inner class name */ public class C0019b implements Iterator { final Iterator a; Collection b; public C0019b() { this.a = b.this.c.entrySet().iterator(); } @Override // java.util.Iterator public boolean hasNext() { return this.a.hasNext(); } @Override // java.util.Iterator /* renamed from: a, reason: merged with bridge method [inline-methods] */ public Map.Entry next() { Map.Entry entry = (Map.Entry) this.a.next(); this.b = (Collection) entry.getValue(); return b.this.a(entry); } @Override // java.util.Iterator public void remove() { p3.a(this.b != null); this.a.remove(); f.b(f.this, this.b.size()); this.b.clear(); this.b = null; } } @Override // java.util.AbstractMap, java.util.Map public Collection get(Object obj) { Collection collection = (Collection) vc.c(this.c, obj); if (collection == null) { return null; } return f.this.a(obj, collection); } @Override // java.util.AbstractMap, java.util.Map public Collection remove(Object obj) { Collection collection = (Collection) this.c.remove(obj); if (collection == null) { return null; } Collection g = f.this.g(); g.addAll(collection); f.b(f.this, collection.size()); collection.clear(); return g; } } public class h extends b implements SortedMap { SortedSet f; public SortedSet c() { return f.this.new i(d()); } public SortedMap headMap(Object obj) { return f.this.new h(d().headMap(obj)); } public SortedMap subMap(Object obj, Object obj2) { return f.this.new h(d().subMap(obj, obj2)); } public SortedMap tailMap(Object obj) { return f.this.new h(d().tailMap(obj)); } public h(SortedMap sortedMap) { super(sortedMap); } public SortedMap d() { return (SortedMap) this.c; } @Override // java.util.SortedMap public Comparator comparator() { return d().comparator(); } @Override // java.util.SortedMap public Object firstKey() { return d().firstKey(); } @Override // java.util.SortedMap public Object lastKey() { return d().lastKey(); } @Override // com.applovin.impl.f.b, java.util.AbstractMap, java.util.Map public SortedSet keySet() { SortedSet sortedSet = this.f; if (sortedSet != null) { return sortedSet; } SortedSet c = c(); this.f = c; return c; } } public class e extends h implements NavigableMap { @Override // java.util.NavigableMap public NavigableMap descendingMap() { return f.this.new e(d().descendingMap()); } @Override // com.applovin.impl.f.h /* renamed from: e, reason: merged with bridge method [inline-methods] */ public NavigableSet c() { return f.this.new C0020f(d()); } @Override // java.util.NavigableMap public NavigableMap headMap(Object obj, boolean z) { return f.this.new e(d().headMap(obj, z)); } @Override // java.util.NavigableMap public NavigableMap subMap(Object obj, boolean z, Object obj2, boolean z2) { return f.this.new e(d().subMap(obj, z, obj2, z2)); } @Override // java.util.NavigableMap public NavigableMap tailMap(Object obj, boolean z) { return f.this.new e(d().tailMap(obj, z)); } public e(NavigableMap navigableMap) { super(navigableMap); } @Override // com.applovin.impl.f.h /* renamed from: f, reason: merged with bridge method [inline-methods] */ public NavigableMap d() { return (NavigableMap) super.d(); } @Override // java.util.NavigableMap public Map.Entry lowerEntry(Object obj) { Map.Entry lowerEntry = d().lowerEntry(obj); if (lowerEntry == null) { return null; } return a(lowerEntry); } @Override // java.util.NavigableMap public Object lowerKey(Object obj) { return d().lowerKey(obj); } @Override // java.util.NavigableMap public Map.Entry floorEntry(Object obj) { Map.Entry floorEntry = d().floorEntry(obj); if (floorEntry == null) { return null; } return a(floorEntry); } @Override // java.util.NavigableMap public Object floorKey(Object obj) { return d().floorKey(obj); } @Override // java.util.NavigableMap public Map.Entry ceilingEntry(Object obj) { Map.Entry ceilingEntry = d().ceilingEntry(obj); if (ceilingEntry == null) { return null; } return a(ceilingEntry); } @Override // java.util.NavigableMap public Object ceilingKey(Object obj) { return d().ceilingKey(obj); } @Override // java.util.NavigableMap public Map.Entry higherEntry(Object obj) { Map.Entry higherEntry = d().higherEntry(obj); if (higherEntry == null) { return null; } return a(higherEntry); } @Override // java.util.NavigableMap public Object higherKey(Object obj) { return d().higherKey(obj); } @Override // java.util.NavigableMap public Map.Entry firstEntry() { Map.Entry firstEntry = d().firstEntry(); if (firstEntry == null) { return null; } return a(firstEntry); } @Override // java.util.NavigableMap public Map.Entry lastEntry() { Map.Entry lastEntry = d().lastEntry(); if (lastEntry == null) { return null; } return a(lastEntry); } @Override // java.util.NavigableMap public Map.Entry pollFirstEntry() { return a(entrySet().iterator()); } @Override // java.util.NavigableMap public Map.Entry pollLastEntry() { return a(descendingMap().entrySet().iterator()); } @Override // com.applovin.impl.f.h, com.applovin.impl.f.b, java.util.AbstractMap, java.util.Map public NavigableSet keySet() { return (NavigableSet) super.keySet(); } @Override // java.util.NavigableMap public NavigableSet navigableKeySet() { return keySet(); } @Override // java.util.NavigableMap public NavigableSet descendingKeySet() { return descendingMap().navigableKeySet(); } @Override // com.applovin.impl.f.h, java.util.SortedMap, java.util.NavigableMap /* renamed from: a, reason: merged with bridge method [inline-methods] */ public NavigableMap headMap(Object obj) { return headMap(obj, false); } @Override // com.applovin.impl.f.h, java.util.SortedMap, java.util.NavigableMap /* renamed from: b, reason: merged with bridge method [inline-methods] */ public NavigableMap tailMap(Object obj) { return tailMap(obj, true); } public Map.Entry a(Iterator it) { if (!it.hasNext()) { return null; } Map.Entry entry = (Map.Entry) it.next(); Collection g = f.this.g(); g.addAll((Collection) entry.getValue()); it.remove(); return vc.a(entry.getKey(), f.this.c(g)); } @Override // com.applovin.impl.f.h, java.util.SortedMap, java.util.NavigableMap /* renamed from: a, reason: merged with bridge method [inline-methods] */ public NavigableMap subMap(Object obj, Object obj2) { return subMap(obj, true, obj2, false); } } }