220 lines
6.8 KiB
Java
220 lines
6.8 KiB
Java
package com.google.common.collect;
|
|
|
|
import com.google.common.collect.AbstractObjectCountMap;
|
|
import com.google.common.collect.Multiset;
|
|
import java.util.Arrays;
|
|
import java.util.Collection;
|
|
import java.util.ConcurrentModificationException;
|
|
import java.util.Iterator;
|
|
import java.util.NoSuchElementException;
|
|
import java.util.Set;
|
|
|
|
/* loaded from: classes.dex */
|
|
class ObjectCountLinkedHashMap<K> extends ObjectCountHashMap<K> {
|
|
transient long[] k;
|
|
private transient int l;
|
|
private transient int m;
|
|
|
|
private abstract class LinkedItr<T> implements Iterator<T> {
|
|
private int a;
|
|
private int b;
|
|
private int c;
|
|
|
|
private LinkedItr() {
|
|
this.a = ObjectCountLinkedHashMap.this.l;
|
|
this.b = -1;
|
|
this.c = ObjectCountLinkedHashMap.this.d;
|
|
}
|
|
|
|
private void a() {
|
|
if (ObjectCountLinkedHashMap.this.d != this.c) {
|
|
throw new ConcurrentModificationException();
|
|
}
|
|
}
|
|
|
|
abstract T a(int i);
|
|
|
|
@Override // java.util.Iterator
|
|
public boolean hasNext() {
|
|
return this.a != -2;
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public T next() {
|
|
a();
|
|
if (!hasNext()) {
|
|
throw new NoSuchElementException();
|
|
}
|
|
T a = a(this.a);
|
|
int i = this.a;
|
|
this.b = i;
|
|
this.a = ObjectCountLinkedHashMap.this.j(i);
|
|
return a;
|
|
}
|
|
|
|
@Override // java.util.Iterator
|
|
public void remove() {
|
|
a();
|
|
CollectPreconditions.a(this.b != -1);
|
|
ObjectCountLinkedHashMap objectCountLinkedHashMap = ObjectCountLinkedHashMap.this;
|
|
objectCountLinkedHashMap.c(objectCountLinkedHashMap.a[this.b]);
|
|
if (this.a >= ObjectCountLinkedHashMap.this.h()) {
|
|
this.a = this.b;
|
|
}
|
|
this.c = ObjectCountLinkedHashMap.this.d;
|
|
this.b = -1;
|
|
}
|
|
}
|
|
|
|
ObjectCountLinkedHashMap() {
|
|
this(3);
|
|
}
|
|
|
|
private void b(int i, int i2) {
|
|
if (i == -2) {
|
|
this.l = i2;
|
|
} else {
|
|
c(i, i2);
|
|
}
|
|
if (i2 == -2) {
|
|
this.m = i;
|
|
} else {
|
|
a(i2, i);
|
|
}
|
|
}
|
|
|
|
private void c(int i, int i2) {
|
|
long[] jArr = this.k;
|
|
jArr[i] = (jArr[i] & (-4294967296L)) | (i2 & 4294967295L);
|
|
}
|
|
|
|
private int i(int i) {
|
|
return (int) (this.k[i] >>> 32);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public int j(int i) {
|
|
return (int) this.k[i];
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractObjectCountMap
|
|
int d(int i) {
|
|
int j = j(i);
|
|
if (j == -2) {
|
|
return -1;
|
|
}
|
|
return j;
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractObjectCountMap
|
|
int e() {
|
|
int i = this.l;
|
|
if (i == -2) {
|
|
return -1;
|
|
}
|
|
return i;
|
|
}
|
|
|
|
@Override // com.google.common.collect.ObjectCountHashMap
|
|
void f(int i) {
|
|
int h = h() - 1;
|
|
b(i(i), j(i));
|
|
if (i < h) {
|
|
b(i(h), i);
|
|
b(i, j(h));
|
|
}
|
|
super.f(i);
|
|
}
|
|
|
|
@Override // com.google.common.collect.ObjectCountHashMap
|
|
void g(int i) {
|
|
super.g(i);
|
|
this.k = Arrays.copyOf(this.k, i);
|
|
}
|
|
|
|
ObjectCountLinkedHashMap(int i) {
|
|
this(i, 1.0f);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractObjectCountMap
|
|
Set<K> c() {
|
|
return new AbstractObjectCountMap<K>.KeySetView() { // from class: com.google.common.collect.ObjectCountLinkedHashMap.1
|
|
@Override // com.google.common.collect.AbstractObjectCountMap.KeySetView, java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
|
|
public Iterator<K> iterator() {
|
|
return new ObjectCountLinkedHashMap<K>.LinkedItr<K>() { // from class: com.google.common.collect.ObjectCountLinkedHashMap.1.1
|
|
{
|
|
ObjectCountLinkedHashMap objectCountLinkedHashMap = ObjectCountLinkedHashMap.this;
|
|
}
|
|
|
|
@Override // com.google.common.collect.ObjectCountLinkedHashMap.LinkedItr
|
|
K a(int i) {
|
|
return (K) ObjectCountLinkedHashMap.this.a[i];
|
|
}
|
|
};
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractObjectCountMap.KeySetView, java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public Object[] toArray() {
|
|
return ObjectArrays.a(this);
|
|
}
|
|
|
|
@Override // com.google.common.collect.AbstractObjectCountMap.KeySetView, java.util.AbstractCollection, java.util.Collection, java.util.Set
|
|
public <T> T[] toArray(T[] tArr) {
|
|
return (T[]) ObjectArrays.a((Collection<?>) this, (Object[]) tArr);
|
|
}
|
|
};
|
|
}
|
|
|
|
ObjectCountLinkedHashMap(int i, float f) {
|
|
super(i, f);
|
|
}
|
|
|
|
@Override // com.google.common.collect.ObjectCountHashMap
|
|
void a(int i, float f) {
|
|
super.a(i, f);
|
|
this.l = -2;
|
|
this.m = -2;
|
|
this.k = new long[i];
|
|
Arrays.fill(this.k, -1L);
|
|
}
|
|
|
|
@Override // com.google.common.collect.ObjectCountHashMap, com.google.common.collect.AbstractObjectCountMap
|
|
Set<Multiset.Entry<K>> b() {
|
|
return new AbstractObjectCountMap<K>.EntrySetView() { // from class: com.google.common.collect.ObjectCountLinkedHashMap.2
|
|
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
|
|
public Iterator<Multiset.Entry<K>> iterator() {
|
|
return new ObjectCountLinkedHashMap<K>.LinkedItr<Multiset.Entry<K>>() { // from class: com.google.common.collect.ObjectCountLinkedHashMap.2.1
|
|
{
|
|
ObjectCountLinkedHashMap objectCountLinkedHashMap = ObjectCountLinkedHashMap.this;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
@Override // com.google.common.collect.ObjectCountLinkedHashMap.LinkedItr
|
|
public Multiset.Entry<K> a(int i) {
|
|
return new AbstractObjectCountMap.MapEntry(i);
|
|
}
|
|
};
|
|
}
|
|
};
|
|
}
|
|
|
|
private void a(int i, int i2) {
|
|
long[] jArr = this.k;
|
|
jArr[i] = (jArr[i] & 4294967295L) | (i2 << 32);
|
|
}
|
|
|
|
@Override // com.google.common.collect.ObjectCountHashMap
|
|
void a(int i, K k, int i2, int i3) {
|
|
super.a(i, k, i2, i3);
|
|
b(this.m, i);
|
|
b(i, -2);
|
|
}
|
|
|
|
@Override // com.google.common.collect.ObjectCountHashMap, com.google.common.collect.AbstractObjectCountMap
|
|
public void a() {
|
|
super.a();
|
|
this.l = -2;
|
|
this.m = -2;
|
|
}
|
|
}
|