package com.google.android.gms.internal.measurement; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; import org.checkerframework.checker.nullness.qual.RequiresNonNull; import org.simpleframework.xml.strategy.Name; /* loaded from: classes.dex */ public final class zzae implements Iterable, zzap, zzal { final SortedMap zza; final Map zzb; public zzae() { this.zza = new TreeMap(); this.zzb = new TreeMap(); } public final boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof zzae)) { return false; } zzae zzaeVar = (zzae) obj; if (zzc() != zzaeVar.zzc()) { return false; } if (this.zza.isEmpty()) { return zzaeVar.zza.isEmpty(); } for (int intValue = this.zza.firstKey().intValue(); intValue <= this.zza.lastKey().intValue(); intValue++) { if (!zze(intValue).equals(zzaeVar.zze(intValue))) { return false; } } return true; } public final int hashCode() { return this.zza.hashCode() * 31; } public final String toString() { return zzj(","); } public final int zzb() { return this.zza.size(); } @Override // com.google.android.gms.internal.measurement.zzap public final zzap zzbK(String str, zzg zzgVar, List list) { if ("concat".equals(str) || "every".equals(str) || "filter".equals(str) || "forEach".equals(str) || "indexOf".equals(str) || "join".equals(str) || "lastIndexOf".equals(str) || "map".equals(str) || "pop".equals(str) || "push".equals(str) || "reduce".equals(str) || "reduceRight".equals(str) || "reverse".equals(str) || "shift".equals(str) || "slice".equals(str) || "some".equals(str) || "sort".equals(str) || "splice".equals(str) || "toString".equals(str) || "unshift".equals(str)) { return zzbb.zza(str, this, zzgVar, list); } return zzaj.zza(this, new zzat(str), zzgVar, list); } public final int zzc() { if (this.zza.isEmpty()) { return 0; } return this.zza.lastKey().intValue() + 1; } @Override // com.google.android.gms.internal.measurement.zzap public final zzap zzd() { zzae zzaeVar = new zzae(); for (Map.Entry entry : this.zza.entrySet()) { if (entry.getValue() instanceof zzal) { zzaeVar.zza.put(entry.getKey(), entry.getValue()); } else { zzaeVar.zza.put(entry.getKey(), entry.getValue().zzd()); } } return zzaeVar; } public final zzap zze(int i) { zzap zzapVar; if (i < zzc()) { return (!zzs(i) || (zzapVar = this.zza.get(Integer.valueOf(i))) == null) ? zzf : zzapVar; } throw new IndexOutOfBoundsException("Attempting to get element outside of current array"); } @Override // com.google.android.gms.internal.measurement.zzal public final zzap zzf(String str) { zzap zzapVar; if (Name.LENGTH.equals(str)) { return new zzah(Double.valueOf(zzc())); } return (!zzt(str) || (zzapVar = this.zzb.get(str)) == null) ? zzf : zzapVar; } @Override // com.google.android.gms.internal.measurement.zzap public final Boolean zzg() { return true; } @Override // com.google.android.gms.internal.measurement.zzap public final Double zzh() { if (this.zza.size() == 1) { return zze(0).zzh(); } if (this.zza.size() <= 0) { return Double.valueOf(0.0d); } return Double.valueOf(Double.NaN); } @Override // com.google.android.gms.internal.measurement.zzap public final String zzi() { return zzj(","); } public final String zzj(String str) { if (str == null) { str = ""; } StringBuilder sb = new StringBuilder(); if (!this.zza.isEmpty()) { for (int i = 0; i < zzc(); i++) { zzap zze = zze(i); sb.append(str); if (!(zze instanceof zzau) && !(zze instanceof zzan)) { sb.append(zze.zzi()); } } sb.delete(0, str.length()); } return sb.toString(); } public final Iterator zzk() { return this.zza.keySet().iterator(); } @Override // com.google.android.gms.internal.measurement.zzap public final Iterator zzl() { return new zzac(this, this.zza.keySet().iterator(), this.zzb.keySet().iterator()); } public final List zzm() { ArrayList arrayList = new ArrayList(zzc()); for (int i = 0; i < zzc(); i++) { arrayList.add(zze(i)); } return arrayList; } public final void zzn() { this.zza.clear(); } public final void zzp(int i) { int intValue = this.zza.lastKey().intValue(); if (i > intValue || i < 0) { return; } this.zza.remove(Integer.valueOf(i)); if (i == intValue) { SortedMap sortedMap = this.zza; int i2 = i - 1; Integer valueOf = Integer.valueOf(i2); if (sortedMap.containsKey(valueOf) || i2 < 0) { return; } this.zza.put(valueOf, zzap.zzf); return; } while (true) { int i3 = i + 1; if (i3 > this.zza.lastKey().intValue()) { return; } SortedMap sortedMap2 = this.zza; Integer valueOf2 = Integer.valueOf(i3); zzap zzapVar = sortedMap2.get(valueOf2); if (zzapVar != null) { this.zza.put(Integer.valueOf(i), zzapVar); this.zza.remove(valueOf2); } i = i3; } } @Override // com.google.android.gms.internal.measurement.zzal public final void zzr(String str, zzap zzapVar) { if (zzapVar == null) { this.zzb.remove(str); } else { this.zzb.put(str, zzapVar); } } public final boolean zzs(int i) { if (i < 0 || i > this.zza.lastKey().intValue()) { StringBuilder sb = new StringBuilder(32); sb.append("Out of bounds index: "); sb.append(i); throw new IndexOutOfBoundsException(sb.toString()); } return this.zza.containsKey(Integer.valueOf(i)); } @Override // com.google.android.gms.internal.measurement.zzal public final boolean zzt(String str) { return Name.LENGTH.equals(str) || this.zzb.containsKey(str); } public final void zzo(int i, zzap zzapVar) { if (i < 0) { StringBuilder sb = new StringBuilder(32); sb.append("Invalid value index: "); sb.append(i); throw new IllegalArgumentException(sb.toString()); } if (i >= zzc()) { zzq(i, zzapVar); return; } for (int intValue = this.zza.lastKey().intValue(); intValue >= i; intValue--) { SortedMap sortedMap = this.zza; Integer valueOf = Integer.valueOf(intValue); zzap zzapVar2 = sortedMap.get(valueOf); if (zzapVar2 != null) { zzq(intValue + 1, zzapVar2); this.zza.remove(valueOf); } } zzq(i, zzapVar); } public zzae(List list) { this(); if (list != null) { for (int i = 0; i < list.size(); i++) { zzq(i, list.get(i)); } } } @RequiresNonNull({"elements"}) public final void zzq(int i, zzap zzapVar) { if (i > 32468) { throw new IllegalStateException("Array too large"); } if (i < 0) { StringBuilder sb = new StringBuilder(32); sb.append("Out of bounds index: "); sb.append(i); throw new IndexOutOfBoundsException(sb.toString()); } if (zzapVar == null) { this.zza.remove(Integer.valueOf(i)); } else { this.zza.put(Integer.valueOf(i), zzapVar); } } @Override // java.lang.Iterable public final Iterator iterator() { return new zzad(this); } }