package com.bytedance.sdk.component.fm;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/* JADX INFO: loaded from: classes.dex */
public class qhl<K, V> {
    private final Map<K, V> fm = new HashMap();
    private final Map<V, Set<K>> ro = new HashMap();

    public void fm(Set<K> set, V v10) {
        for (K k6 : set) {
            if (this.fm.containsKey(k6)) {
                ro(k6);
            }
        }
        Set<K> hashSet = this.ro.get(v10);
        if (hashSet == null) {
            hashSet = new HashSet<>();
            this.ro.put(v10, hashSet);
        }
        hashSet.addAll(set);
        Iterator<K> it = set.iterator();
        while (it.hasNext()) {
            this.fm.put(it.next(), v10);
        }
    }

    public void ro(K k6) {
        Set<K> set;
        V vRemove = this.fm.remove(k6);
        if (vRemove == null || (set = this.ro.get(vRemove)) == null) {
            return;
        }
        set.remove(k6);
        if (set.isEmpty()) {
            this.ro.remove(vRemove);
        }
    }

    public V fm(K k6) {
        return this.fm.get(k6);
    }

    public void fm() {
        this.fm.clear();
        this.ro.clear();
    }
}
