package o; import android.view.View; import android.view.ViewGroup; import androidx.recyclerview.widget.RecyclerView; import java.util.ArrayList; import java.util.List; /* loaded from: classes.dex */ public final class Emo { public final LWm d; public final RVV e = new RVV(); public final List b = new ArrayList(); /* loaded from: classes.dex */ public interface LWm { void Ad_(View view, int i, ViewGroup.LayoutParams layoutParams); int a(View view); void b(int i); void b(View view); void b(View view, int i); int c(); RecyclerView.zJl c(View view); void c(int i); void d(View view); View e(int i); void e(); } public Emo(LWm lWm) { this.d = lWm; } public final void d(View view, int i, boolean z) { int a; if (i < 0) { a = this.d.c(); } else { a = a(i); } this.e.d(a, z); if (z) { this.b.add(view); this.d.d(view); } this.d.b(view, a); } public final int a(int i) { if (i < 0) { return -1; } int c = this.d.c(); int i2 = i; while (i2 < c) { int e = i - (i2 - this.e.e(i2)); if (e == 0) { while (this.e.d(i2)) { i2++; } return i2; } i2 += e; } return -1; } public final void d(View view) { int a = this.d.a(view); if (a < 0) { return; } if (this.e.a(a) && this.b.remove(view)) { this.d.b(view); } this.d.c(a); } public final void e(int i) { int a = a(i); View e = this.d.e(a); if (e == null) { return; } if (this.e.a(a) && this.b.remove(e)) { this.d.b(e); } this.d.c(a); } public final void zG_(View view, int i, ViewGroup.LayoutParams layoutParams, boolean z) { int a; if (i < 0) { a = this.d.c(); } else { a = a(i); } this.e.d(a, z); if (z) { this.b.add(view); this.d.d(view); } this.d.Ad_(view, a, layoutParams); } public final int b(View view) { int a = this.d.a(view); if (a == -1 || this.e.d(a)) { return -1; } return a - this.e.e(a); } public final String toString() { StringBuilder sb = new StringBuilder(); sb.append(this.e.toString()); sb.append(", hidden list:"); sb.append(this.b.size()); return sb.toString(); } /* loaded from: classes.dex */ public static class RVV { public long d = 0; public RVV e; RVV() { } public final void c(int i) { RVV rvv = this; while (i >= 64) { if (rvv.e == null) { rvv.e = new RVV(); } rvv = rvv.e; i -= 64; } rvv.d |= 1 << i; } public final void b(int i) { RVV rvv = this; while (i >= 64) { rvv = rvv.e; if (rvv == null) { return; } else { i -= 64; } } rvv.d &= ~(1 << i); } public final boolean d(int i) { RVV rvv = this; while (i >= 64) { if (rvv.e == null) { rvv.e = new RVV(); } rvv = rvv.e; i -= 64; } return (rvv.d & (1 << i)) != 0; } final void d(int i, boolean z) { RVV rvv = this; while (true) { if (i >= 64) { if (rvv.e == null) { rvv.e = new RVV(); } rvv = rvv.e; i -= 64; } else { long j = rvv.d; boolean z2 = (Long.MIN_VALUE & j) != 0; long j2 = (1 << i) - 1; rvv.d = (j & j2) | (((~j2) & j) << 1); if (z) { rvv.c(i); } else { rvv.b(i); } if (!z2 && rvv.e == null) { return; } if (rvv.e == null) { rvv.e = new RVV(); } rvv = rvv.e; z = z2; i = 0; } } } public final boolean a(int i) { RVV rvv = this; while (i >= 64) { if (rvv.e == null) { rvv.e = new RVV(); } rvv = rvv.e; i -= 64; } long j = 1 << i; long j2 = rvv.d; boolean z = (j2 & j) != 0; long j3 = j2 & (~j); rvv.d = j3; long j4 = j - 1; rvv.d = (j3 & j4) | Long.rotateRight((~j4) & j3, 1); RVV rvv2 = rvv.e; if (rvv2 != null) { if (rvv2.d(0)) { rvv.c(63); } rvv.e.a(0); } return z; } final int e(int i) { RVV rvv = this.e; if (rvv == null) { if (i >= 64) { return Long.bitCount(this.d); } return Long.bitCount(this.d & ((1 << i) - 1)); } if (i < 64) { return Long.bitCount(this.d & ((1 << i) - 1)); } return rvv.e(i - 64) + Long.bitCount(this.d); } public final String toString() { if (this.e == null) { return Long.toBinaryString(this.d); } StringBuilder sb = new StringBuilder(); sb.append(this.e.toString()); sb.append("xx"); sb.append(Long.toBinaryString(this.d)); return sb.toString(); } } }