Rabbit-R1/switch port/java/sources/com/google/common/graph/MultiEdgesConnecting.java
2024-05-21 17:08:36 -04:00

45 lines
1.8 KiB
Java

package com.google.common.graph;
import com.google.common.base.Preconditions;
import com.google.common.collect.AbstractIterator;
import com.google.common.collect.UnmodifiableIterator;
import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Map;
import javax.annotation.CheckForNull;
@ElementTypesAreNonnullByDefault
/* loaded from: classes3.dex */
abstract class MultiEdgesConnecting<E> extends AbstractSet<E> {
private final Map<E, ?> outEdgeToNode;
private final Object targetNode;
/* JADX INFO: Access modifiers changed from: package-private */
public MultiEdgesConnecting(Map<E, ?> map, Object obj) {
this.outEdgeToNode = (Map) Preconditions.checkNotNull(map);
this.targetNode = Preconditions.checkNotNull(obj);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public UnmodifiableIterator<E> iterator() {
final Iterator<Map.Entry<E, ?>> it = this.outEdgeToNode.entrySet().iterator();
return new AbstractIterator<E>() { // from class: com.google.common.graph.MultiEdgesConnecting.1
@Override // com.google.common.collect.AbstractIterator
@CheckForNull
protected E computeNext() {
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
if (MultiEdgesConnecting.this.targetNode.equals(entry.getValue())) {
return (E) entry.getKey();
}
}
return endOfData();
}
};
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public boolean contains(@CheckForNull Object obj) {
return this.targetNode.equals(this.outEdgeToNode.get(obj));
}
}