74 lines
2.0 KiB
Java
74 lines
2.0 KiB
Java
package com.ubtrobot.analytics;
|
|
|
|
import java.io.IOException;
|
|
import java.util.Iterator;
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class MemoryEventStorage implements EventStorage {
|
|
private final LinkedList<Event> a;
|
|
private final int b;
|
|
|
|
public MemoryEventStorage() {
|
|
this(17895697);
|
|
}
|
|
|
|
@Override // com.ubtrobot.analytics.EventStorage
|
|
public void a(Event event) throws IOException {
|
|
synchronized (this.a) {
|
|
this.a.add(event);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubtrobot.analytics.EventStorage
|
|
public void b(List<Event> list) throws IOException {
|
|
synchronized (this.a) {
|
|
this.a.addAll(list);
|
|
if (this.a.size() <= this.b) {
|
|
return;
|
|
}
|
|
b(this.a.size() - this.b);
|
|
}
|
|
}
|
|
|
|
public MemoryEventStorage(int i) {
|
|
this.a = new LinkedList<>();
|
|
this.b = i;
|
|
}
|
|
|
|
@Override // com.ubtrobot.analytics.EventStorage
|
|
public int a() throws IOException {
|
|
int size;
|
|
synchronized (this.a) {
|
|
size = this.a.size();
|
|
}
|
|
return size;
|
|
}
|
|
|
|
@Override // com.ubtrobot.analytics.EventStorage
|
|
public List<Event> a(int i) throws IOException {
|
|
LinkedList linkedList;
|
|
synchronized (this.a) {
|
|
linkedList = new LinkedList(this.a.subList(0, Math.min(i, this.a.size())));
|
|
}
|
|
return linkedList;
|
|
}
|
|
|
|
@Override // com.ubtrobot.analytics.EventStorage
|
|
public void b(int i) throws IOException {
|
|
synchronized (this.a) {
|
|
Iterator<Event> it = this.a.iterator();
|
|
for (int i2 = 0; it.hasNext() && i2 < i; i2++) {
|
|
it.next();
|
|
it.remove();
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // com.ubtrobot.analytics.EventStorage
|
|
public void a(List<Event> list) throws IOException {
|
|
throw new IllegalStateException("MemoryEventStorage nonsupport removeEvents(List<Event>).");
|
|
}
|
|
}
|