discord-jadx/app/src/main/java/c/i/a/c/i2/d0.java

91 lines
2.3 KiB
Java
Raw Normal View History

2021-07-24 02:37:17 +00:00
package c.i.a.c.i2;
import androidx.annotation.Nullable;
import com.airbnb.lottie.parser.AnimatableValueParser;
import java.util.Arrays;
/* compiled from: TimedValueQueue */
public final class d0<V> {
public long[] a = new long[10];
public V[] b = ((V[]) new Object[10]);
/* renamed from: c reason: collision with root package name */
2021-07-28 07:39:21 +00:00
public int f902c;
2021-07-24 02:37:17 +00:00
public int d;
public synchronized void a(long j, V v) {
int i = this.d;
if (i > 0) {
2021-07-28 07:39:21 +00:00
if (j <= this.a[((this.f902c + i) - 1) % this.b.length]) {
2021-07-24 02:37:17 +00:00
b();
}
}
c();
2021-07-28 07:39:21 +00:00
int i2 = this.f902c;
2021-07-24 02:37:17 +00:00
int i3 = this.d;
V[] vArr = this.b;
int length = (i2 + i3) % vArr.length;
this.a[length] = j;
vArr[length] = v;
this.d = i3 + 1;
}
public synchronized void b() {
2021-07-28 07:39:21 +00:00
this.f902c = 0;
2021-07-24 02:37:17 +00:00
this.d = 0;
Arrays.fill(this.b, (Object) null);
}
public final void c() {
int length = this.b.length;
if (this.d >= length) {
int i = length * 2;
long[] jArr = new long[i];
V[] vArr = (V[]) new Object[i];
2021-07-28 07:39:21 +00:00
int i2 = this.f902c;
2021-07-24 02:37:17 +00:00
int i3 = length - i2;
System.arraycopy(this.a, i2, jArr, 0, i3);
2021-07-28 07:39:21 +00:00
System.arraycopy(this.b, this.f902c, vArr, 0, i3);
int i4 = this.f902c;
2021-07-24 02:37:17 +00:00
if (i4 > 0) {
System.arraycopy(this.a, 0, jArr, i3, i4);
2021-07-28 07:39:21 +00:00
System.arraycopy(this.b, 0, vArr, i3, this.f902c);
2021-07-24 02:37:17 +00:00
}
this.a = jArr;
this.b = vArr;
2021-07-28 07:39:21 +00:00
this.f902c = 0;
2021-07-24 02:37:17 +00:00
}
}
@Nullable
public final V d(long j, boolean z2) {
V v = null;
long j2 = Long.MAX_VALUE;
while (this.d > 0) {
2021-07-28 07:39:21 +00:00
long j3 = j - this.a[this.f902c];
2021-07-24 02:37:17 +00:00
if (j3 < 0 && (z2 || (-j3) >= j2)) {
break;
}
v = f();
j2 = j3;
}
return v;
}
@Nullable
public synchronized V e(long j) {
return d(j, true);
}
@Nullable
public final V f() {
AnimatableValueParser.D(this.d > 0);
V[] vArr = this.b;
2021-07-28 07:39:21 +00:00
int i = this.f902c;
2021-07-24 02:37:17 +00:00
V v = vArr[i];
vArr[i] = null;
2021-07-28 07:39:21 +00:00
this.f902c = (i + 1) % vArr.length;
2021-07-24 02:37:17 +00:00
this.d--;
return v;
}
}