91 lines
2.3 KiB
Java
91 lines
2.3 KiB
Java
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 */
|
|
public int f902c;
|
|
public int d;
|
|
|
|
public synchronized void a(long j, V v) {
|
|
int i = this.d;
|
|
if (i > 0) {
|
|
if (j <= this.a[((this.f902c + i) - 1) % this.b.length]) {
|
|
b();
|
|
}
|
|
}
|
|
c();
|
|
int i2 = this.f902c;
|
|
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() {
|
|
this.f902c = 0;
|
|
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];
|
|
int i2 = this.f902c;
|
|
int i3 = length - i2;
|
|
System.arraycopy(this.a, i2, jArr, 0, i3);
|
|
System.arraycopy(this.b, this.f902c, vArr, 0, i3);
|
|
int i4 = this.f902c;
|
|
if (i4 > 0) {
|
|
System.arraycopy(this.a, 0, jArr, i3, i4);
|
|
System.arraycopy(this.b, 0, vArr, i3, this.f902c);
|
|
}
|
|
this.a = jArr;
|
|
this.b = vArr;
|
|
this.f902c = 0;
|
|
}
|
|
}
|
|
|
|
@Nullable
|
|
public final V d(long j, boolean z2) {
|
|
V v = null;
|
|
long j2 = Long.MAX_VALUE;
|
|
while (this.d > 0) {
|
|
long j3 = j - this.a[this.f902c];
|
|
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;
|
|
int i = this.f902c;
|
|
V v = vArr[i];
|
|
vArr[i] = null;
|
|
this.f902c = (i + 1) % vArr.length;
|
|
this.d--;
|
|
return v;
|
|
}
|
|
}
|