package com.discord.utilities.collections; import c.d.b.a.a; import d0.t.u; import d0.z.d.g; import d0.z.d.g0.e; import d0.z.d.m; import java.util.Collection; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Set; import kotlin.jvm.internal.DefaultConstructorMarker; /* compiled from: LeastRecentlyAddedSet.kt */ public final class LeastRecentlyAddedSet implements Set, e { private final LinkedHashSet _set; private final int maxSize; public LeastRecentlyAddedSet() { this(0, null, 3, null); } public LeastRecentlyAddedSet(int i, LinkedHashSet linkedHashSet) { m.checkNotNullParameter(linkedHashSet, "_set"); this.maxSize = i; this._set = linkedHashSet; } /* JADX WARNING: Illegal instructions before constructor call */ public /* synthetic */ LeastRecentlyAddedSet(int i, LinkedHashSet linkedHashSet, int i2, DefaultConstructorMarker defaultConstructorMarker) { this(i, (i2 & 2) != 0 ? new LinkedHashSet(i) : linkedHashSet); i = (i2 & 1) != 0 ? 3 : i; } @Override // java.util.Set, java.util.Collection public synchronized boolean add(E e) { boolean remove; remove = this._set.remove(e); Iterator it = this._set.iterator(); m.checkNotNullExpressionValue(it, "_set.iterator()"); while (this._set.size() >= this.maxSize) { it.next(); it.remove(); } this._set.add(e); return !remove; } @Override // java.util.Set, java.util.Collection public boolean addAll(Collection collection) { m.checkNotNullParameter(collection, "elements"); return this._set.addAll(collection); } @Override // java.util.Set, java.util.Collection public void clear() { this._set.clear(); } @Override // java.util.Set, java.util.Collection public boolean contains(Object obj) { return this._set.contains(obj); } @Override // java.util.Set, java.util.Collection public boolean containsAll(Collection collection) { m.checkNotNullParameter(collection, "elements"); return this._set.containsAll(collection); } public final int getMaxSize() { return this.maxSize; } public int getSize() { return this._set.size(); } @Override // java.util.Set, java.util.Collection public boolean isEmpty() { return this._set.isEmpty(); } @Override // java.util.Set, java.util.Collection, java.lang.Iterable public Iterator iterator() { Iterator it = this._set.iterator(); m.checkNotNullExpressionValue(it, "iterator(...)"); return it; } @Override // java.util.Set, java.util.Collection public boolean remove(Object obj) { return this._set.remove(obj); } @Override // java.util.Set, java.util.Collection public boolean removeAll(Collection collection) { m.checkNotNullParameter(collection, "elements"); return this._set.removeAll(collection); } @Override // java.util.Set, java.util.Collection public boolean retainAll(Collection collection) { m.checkNotNullParameter(collection, "elements"); return this._set.retainAll(collection); } @Override // java.util.Set, java.util.Collection public final /* bridge */ int size() { return getSize(); } @Override // java.util.Set, java.util.Collection public Object[] toArray() { return g.toArray(this); } @Override // java.util.Set, java.util.Collection public T[] toArray(T[] tArr) { return (T[]) g.toArray(this, tArr); } @Override // java.lang.Object public String toString() { StringBuilder L = a.L("LRA Set "); L.append(u.toList(this._set)); return L.toString(); } }