package com.bytedance.ies.nle.editor_jni;

import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import java.util.AbstractSet;
import java.util.Collection;
import java.util.NoSuchElementException;

public class SetString extends AbstractSet<String> {
    public transient boolean LIZ;
    public transient long LIZIZ;

    static {
        Covode.recordClassIndex(29913);
    }

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

        static {
            Covode.recordClassIndex(29915);
        }

        public void finalize() {
            LIZ();
        }

        private synchronized void LIZ() {
            MethodCollector.i(7611);
            long j = this.LIZ;
            if (j != 0) {
                if (this.LIZIZ) {
                    this.LIZIZ = false;
                    NLETemplateJNI.delete_SetString_Iterator(j);
                }
                this.LIZ = 0;
            }
            MethodCollector.o(7611);
        }

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

    public void finalize() {
        LIZ();
    }

    public SetString() {
        this(NLETemplateJNI.new_SetString__SWIG_0());
        MethodCollector.i(9778);
        MethodCollector.o(9778);
    }

    public void clear() {
        MethodCollector.i(9780);
        NLETemplateJNI.SetString_clear(this.LIZIZ, this);
        MethodCollector.o(9780);
    }

    public boolean isEmpty() {
        MethodCollector.i(9779);
        boolean SetString_isEmpty = NLETemplateJNI.SetString_isEmpty(this.LIZIZ, this);
        MethodCollector.o(9779);
        return SetString_isEmpty;
    }

    public int size() {
        MethodCollector.i(9592);
        int SetString_sizeImpl = NLETemplateJNI.SetString_sizeImpl(this.LIZIZ, this);
        MethodCollector.o(9592);
        return SetString_sizeImpl;
    }

    private synchronized void LIZ() {
        MethodCollector.i(9590);
        long j = this.LIZIZ;
        if (j != 0) {
            if (this.LIZ) {
                this.LIZ = false;
                NLETemplateJNI.delete_SetString(j);
            }
            this.LIZIZ = 0;
        }
        MethodCollector.o(9590);
    }

    public java.util.Iterator<String> iterator() {
        MethodCollector.i(9773);
        AnonymousClass1 r4 = new java.util.Iterator<String>() {
            public Iterator LIZ;
            public Iterator LIZIZ;

            static {
                Covode.recordClassIndex(29914);
            }

            public final boolean hasNext() {
                long j;
                MethodCollector.i(9191);
                Iterator iterator = this.LIZ;
                Iterator iterator2 = this.LIZIZ;
                long j2 = iterator.LIZ;
                if (iterator2 == null) {
                    j = 0;
                } else {
                    j = iterator2.LIZ;
                }
                boolean SetString_Iterator_isNot = NLETemplateJNI.SetString_Iterator_isNot(j2, iterator, j, iterator2);
                MethodCollector.o(9191);
                return SetString_Iterator_isNot;
            }

            public final /* synthetic */ Object next() {
                MethodCollector.i(9585);
                if (hasNext()) {
                    Iterator iterator = this.LIZ;
                    String SetString_Iterator_derefUnchecked = NLETemplateJNI.SetString_Iterator_derefUnchecked(iterator.LIZ, iterator);
                    Iterator iterator2 = this.LIZ;
                    NLETemplateJNI.SetString_Iterator_incrementUnchecked(iterator2.LIZ, iterator2);
                    MethodCollector.o(9585);
                    return SetString_Iterator_derefUnchecked;
                }
                NoSuchElementException noSuchElementException = new NoSuchElementException();
                MethodCollector.o(9585);
                throw noSuchElementException;
            }
        };
        SetString setString = SetString.this;
        r4.LIZ = new Iterator(NLETemplateJNI.SetString_begin(setString.LIZIZ, setString));
        SetString setString2 = SetString.this;
        r4.LIZIZ = new Iterator(NLETemplateJNI.SetString_end(setString2.LIZIZ, setString2));
        MethodCollector.o(9773);
        return r4;
    }

    /* access modifiers changed from: private */
    /* renamed from: LIZ */
    public boolean add(String str) {
        MethodCollector.i(10013);
        boolean SetString_add = NLETemplateJNI.SetString_add(this.LIZIZ, this, str);
        MethodCollector.o(10013);
        return SetString_add;
    }

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

    public boolean addAll(Collection<? extends String> collection) {
        boolean z = false;
        for (String LIZ2 : collection) {
            z |= add(LIZ2);
        }
        return z;
    }

    public boolean contains(Object obj) {
        MethodCollector.i(9776);
        if (!(obj instanceof String)) {
            MethodCollector.o(9776);
            return false;
        }
        boolean SetString_containsImpl = NLETemplateJNI.SetString_containsImpl(this.LIZIZ, this, (String) obj);
        MethodCollector.o(9776);
        return SetString_containsImpl;
    }

    public boolean containsAll(Collection<?> collection) {
        for (Object contains : collection) {
            if (!contains(contains)) {
                return false;
            }
        }
        return true;
    }

    public boolean remove(Object obj) {
        MethodCollector.i(9777);
        if (!(obj instanceof String)) {
            MethodCollector.o(9777);
            return false;
        }
        boolean SetString_removeImpl = NLETemplateJNI.SetString_removeImpl(this.LIZIZ, this, (String) obj);
        MethodCollector.o(9777);
        return SetString_removeImpl;
    }

    public boolean removeAll(Collection<?> collection) {
        boolean z = false;
        for (Object remove : collection) {
            z |= remove(remove);
        }
        return z;
    }
}
