package ඓ.ῲ.K.ᕣ.ᨨ.ゎ;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import ඓ.ῲ.K.ᕣ.ᨨ.ゎ.AbstractC0971;

/* renamed from: ඓ.ῲ.K.ᕣ.ᨨ.ゎ.ⁱ  reason: contains not printable characters */
/* compiled from: GroupedLinkedMap */
public class C0968<K extends AbstractC0971, V> {

    /* renamed from: ῲ  reason: contains not printable characters */
    public final Map<K, C0969<K, V>> f4339 = new HashMap();

    /* renamed from: K  reason: contains not printable characters */
    public final C0969<K, V> f4340 = new C0969<>(null);

    /* renamed from: ඓ.ῲ.K.ᕣ.ᨨ.ゎ.ⁱ$K  reason: contains not printable characters */
    /* compiled from: GroupedLinkedMap */
    public static class C0969<K, V> {

        /* renamed from: ʬ  reason: contains not printable characters */
        public C0969<K, V> f4341;

        /* renamed from: ῲ  reason: contains not printable characters */
        public List<V> f4342;

        /* renamed from: K  reason: contains not printable characters */
        public final K f4343;

        /* renamed from: 㸾  reason: contains not printable characters */
        public C0969<K, V> f4344;

        public C0969() {
            this(null);
        }

        /* renamed from: K  reason: contains not printable characters */
        public V m2751() {
            List<V> list = this.f4342;
            int size = list != null ? list.size() : 0;
            if (size > 0) {
                return this.f4342.remove(size - 1);
            }
            return null;
        }

        public C0969(K k) {
            this.f4344 = this;
            this.f4341 = this;
            this.f4343 = k;
        }
    }

    public String toString() {
        StringBuilder sb = new StringBuilder("GroupedLinkedMap( ");
        boolean z = false;
        for (C0969<K, V> k = this.f4340.f4341; !k.equals(this.f4340); k = k.f4341) {
            z = true;
            sb.append('{');
            sb.append((Object) k.f4343);
            sb.append(':');
            List<V> list = k.f4342;
            sb.append(list != null ? list.size() : 0);
            sb.append("}, ");
        }
        if (z) {
            sb.delete(sb.length() - 2, sb.length());
        }
        sb.append(" )");
        return sb.toString();
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m2750(K k, V v) {
        C0969<K, V> k2 = this.f4339.get(k);
        if (k2 == null) {
            k2 = new C0969<>(k);
            C0969<K, V> k3 = k2.f4344;
            k3.f4341 = k2.f4341;
            k2.f4341.f4344 = k3;
            C0969<K, V> k4 = this.f4340;
            k2.f4344 = k4.f4344;
            k2.f4341 = k4;
            m2747(k2);
            this.f4339.put(k, k2);
        } else {
            k.m2754();
        }
        if (k2.f4342 == null) {
            k2.f4342 = new ArrayList();
        }
        k2.f4342.add(v);
    }

    /* renamed from: K  reason: contains not printable characters */
    public V m2749(K k) {
        C0969<K, V> k2 = this.f4339.get(k);
        if (k2 == null) {
            k2 = new C0969<>(k);
            this.f4339.put(k, k2);
        } else {
            k.m2754();
        }
        C0969<K, V> k3 = k2.f4344;
        k3.f4341 = k2.f4341;
        k2.f4341.f4344 = k3;
        C0969<K, V> k4 = this.f4340;
        k2.f4344 = k4;
        k2.f4341 = k4.f4341;
        k2.f4341.f4344 = k2;
        k2.f4344.f4341 = k2;
        return k2.m2751();
    }

    /* renamed from: K  reason: contains not printable characters */
    public V m2748() {
        for (C0969<K, V> k = this.f4340.f4344; !k.equals(this.f4340); k = k.f4344) {
            V r1 = k.m2751();
            if (r1 != null) {
                return r1;
            }
            C0969<K, V> k2 = k.f4344;
            k2.f4341 = k.f4341;
            k.f4341.f4344 = k2;
            this.f4339.remove(k.f4343);
            k.f4343.m2754();
        }
        return null;
    }

    /* renamed from: K  reason: contains not printable characters */
    public static <K, V> void m2747(C0969<K, V> k) {
        k.f4341.f4344 = k;
        k.f4344.f4341 = k;
    }
}
