package com.bytedance.ies.nle.editor_jni;

import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import java.util.AbstractMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class MapStrNLENodeSPtr extends AbstractMap<String, NLENode> {
    public transient boolean LIZ;
    public transient long LIZIZ;

    static {
        Covode.recordClassIndex(29759);
    }

    public static class Iterator {
        public transient long LIZ;
        public transient boolean LIZIZ = true;

        static {
            Covode.recordClassIndex(29761);
        }

        public void finalize() {
            LIZJ();
        }

        public final Iterator LIZ() {
            MethodCollector.i(12579);
            Iterator iterator = new Iterator(NLEEditorJniJNI.MapStrNLENodeSPtr_Iterator_getNextUnchecked(this.LIZ, this));
            MethodCollector.o(12579);
            return iterator;
        }

        public final NLENode LIZIZ() {
            MethodCollector.i(12582);
            long MapStrNLENodeSPtr_Iterator_getValue = NLEEditorJniJNI.MapStrNLENodeSPtr_Iterator_getValue(this.LIZ, this);
            if (MapStrNLENodeSPtr_Iterator_getValue == 0) {
                MethodCollector.o(12582);
                return null;
            }
            NLENode nLENode = new NLENode(MapStrNLENodeSPtr_Iterator_getValue, true);
            MethodCollector.o(12582);
            return nLENode;
        }

        private synchronized void LIZJ() {
            MethodCollector.i(12356);
            long j = this.LIZ;
            if (j != 0) {
                if (this.LIZIZ) {
                    this.LIZIZ = false;
                    NLEEditorJniJNI.delete_MapStrNLENodeSPtr_Iterator(j);
                }
                this.LIZ = 0;
            }
            MethodCollector.o(12356);
        }

        public static long LIZ(Iterator iterator) {
            if (iterator == null) {
                return 0;
            }
            return iterator.LIZ;
        }

        public Iterator(long j) {
            this.LIZ = j;
        }

        public final void LIZ(NLENode nLENode) {
            MethodCollector.i(12583);
            NLENode nLENode2 = nLENode;
            NLEEditorJniJNI.MapStrNLENodeSPtr_Iterator_setValue(this.LIZ, this, NLENode.getCPtr(nLENode2), nLENode2);
            MethodCollector.o(12583);
        }

        public final boolean LIZIZ(Iterator iterator) {
            MethodCollector.i(12580);
            Iterator iterator2 = iterator;
            boolean MapStrNLENodeSPtr_Iterator_isNot = NLEEditorJniJNI.MapStrNLENodeSPtr_Iterator_isNot(this.LIZ, this, LIZ(iterator2), iterator2);
            MethodCollector.o(12580);
            return MapStrNLENodeSPtr_Iterator_isNot;
        }
    }

    public void finalize() {
        LIZ();
    }

    public MapStrNLENodeSPtr() {
        this(NLEEditorJniJNI.new_MapStrNLENodeSPtr__SWIG_0());
        MethodCollector.i(18879);
        MethodCollector.o(18879);
    }

    public void clear() {
        MethodCollector.i(18881);
        NLEEditorJniJNI.MapStrNLENodeSPtr_clear(this.LIZIZ, this);
        MethodCollector.o(18881);
    }

    public boolean isEmpty() {
        MethodCollector.i(18880);
        boolean MapStrNLENodeSPtr_isEmpty = NLEEditorJniJNI.MapStrNLENodeSPtr_isEmpty(this.LIZIZ, this);
        MethodCollector.o(18880);
        return MapStrNLENodeSPtr_isEmpty;
    }

    public int size() {
        MethodCollector.i(18804);
        int MapStrNLENodeSPtr_sizeImpl = NLEEditorJniJNI.MapStrNLENodeSPtr_sizeImpl(this.LIZIZ, this);
        MethodCollector.o(18804);
        return MapStrNLENodeSPtr_sizeImpl;
    }

    private Iterator LIZIZ() {
        MethodCollector.i(8665);
        Iterator iterator = new Iterator(NLEEditorJniJNI.MapStrNLENodeSPtr_end(this.LIZIZ, this));
        MethodCollector.o(8665);
        return iterator;
    }

    private synchronized void LIZ() {
        MethodCollector.i(18803);
        long j = this.LIZIZ;
        if (j != 0) {
            if (this.LIZ) {
                this.LIZ = false;
                NLEEditorJniJNI.delete_MapStrNLENodeSPtr(j);
            }
            this.LIZIZ = 0;
        }
        MethodCollector.o(18803);
    }

    public Set<Map.Entry<String, NLENode>> entrySet() {
        MethodCollector.i(18836);
        HashSet hashSet = new HashSet();
        Iterator LIZIZ2 = LIZIZ();
        for (Iterator iterator = new Iterator(NLEEditorJniJNI.MapStrNLENodeSPtr_begin(this.LIZIZ, this)); iterator.LIZIZ(LIZIZ2); iterator = iterator.LIZ()) {
            AnonymousClass1 r0 = new Map.Entry<String, NLENode>() {
                public Iterator LIZ;

                static {
                    Covode.recordClassIndex(29760);
                }

                public final /* synthetic */ Object getValue() {
                    return this.LIZ.LIZIZ();
                }

                public final /* synthetic */ Object getKey() {
                    MethodCollector.i(12581);
                    Iterator iterator = this.LIZ;
                    String MapStrNLENodeSPtr_Iterator_getKey = NLEEditorJniJNI.MapStrNLENodeSPtr_Iterator_getKey(iterator.LIZ, iterator);
                    MethodCollector.o(12581);
                    return MapStrNLENodeSPtr_Iterator_getKey;
                }

                public final /* synthetic */ Object setValue(Object obj) {
                    NLENode LIZIZ2 = this.LIZ.LIZIZ();
                    this.LIZ.LIZ((NLENode) obj);
                    return LIZIZ2;
                }
            };
            r0.LIZ = iterator;
            hashSet.add(r0);
        }
        MethodCollector.o(18836);
        return hashSet;
    }

    public MapStrNLENodeSPtr(long j) {
        this.LIZ = true;
        this.LIZIZ = j;
    }

    private Iterator LIZ(String str) {
        MethodCollector.i(18882);
        Iterator iterator = new Iterator(NLEEditorJniJNI.MapStrNLENodeSPtr_find(this.LIZIZ, this, str));
        MethodCollector.o(18882);
        return iterator;
    }

    public boolean containsKey(Object obj) {
        MethodCollector.i(18805);
        if (!(obj instanceof String)) {
            MethodCollector.o(18805);
            return false;
        }
        boolean MapStrNLENodeSPtr_containsImpl = NLEEditorJniJNI.MapStrNLENodeSPtr_containsImpl(this.LIZIZ, this, (String) obj);
        MethodCollector.o(18805);
        return MapStrNLENodeSPtr_containsImpl;
    }

    public /* synthetic */ Object get(Object obj) {
        if (!(obj instanceof String)) {
            return null;
        }
        Iterator LIZ2 = LIZ((String) obj);
        if (LIZ2.LIZIZ(LIZIZ())) {
            return LIZ2.LIZIZ();
        }
        return null;
    }

    public /* synthetic */ Object remove(Object obj) {
        MethodCollector.i(8667);
        if (obj instanceof String) {
            Iterator LIZ2 = LIZ((String) obj);
            if (LIZ2.LIZIZ(LIZIZ())) {
                NLENode LIZIZ2 = LIZ2.LIZIZ();
                NLEEditorJniJNI.MapStrNLENodeSPtr_removeUnchecked(this.LIZIZ, this, Iterator.LIZ(LIZ2), LIZ2);
                MethodCollector.o(8667);
                return LIZIZ2;
            }
        }
        MethodCollector.o(8667);
        return null;
    }

    public /* synthetic */ Object put(Object obj, Object obj2) {
        MethodCollector.i(8866);
        String str = (String) obj;
        NLENode nLENode = (NLENode) obj2;
        Iterator LIZ2 = LIZ(str);
        if (LIZ2.LIZIZ(LIZIZ())) {
            NLENode LIZIZ2 = LIZ2.LIZIZ();
            LIZ2.LIZ(nLENode);
            MethodCollector.o(8866);
            return LIZIZ2;
        }
        NLEEditorJniJNI.MapStrNLENodeSPtr_putUnchecked(this.LIZIZ, this, str, NLENode.getCPtr(nLENode), nLENode);
        MethodCollector.o(8866);
        return null;
    }
}
