// 
// Decompiled by Procyon v0.6.0
// 

package it.unimi.dsi.fastutil.booleans;

import java.util.stream.Stream;
import java.util.Iterator;
import java.util.Spliterator;
import java.util.function.Predicate;
import java.util.Collection;
import java.util.function.Consumer;
import java.util.Set;
import java.io.Serializable;

public final class BooleanSets
{
    static final int ARRAY_SET_CUTOFF = 4;
    public static final EmptySet EMPTY_SET;
    static final BooleanSet UNMODIFIABLE_EMPTY_SET;
    
    private BooleanSets() {
    }
    
    public static BooleanSet emptySet() {
        return BooleanSets.EMPTY_SET;
    }
    
    public static BooleanSet singleton(final boolean element) {
        return new Singleton(element);
    }
    
    public static BooleanSet singleton(final Boolean element) {
        return new Singleton(element);
    }
    
    public static BooleanSet synchronize(final BooleanSet s) {
        return new SynchronizedSet(s);
    }
    
    public static BooleanSet synchronize(final BooleanSet s, final Object sync) {
        return new SynchronizedSet(s, sync);
    }
    
    public static BooleanSet unmodifiable(final BooleanSet s) {
        return new UnmodifiableSet(s);
    }
    
    static {
        EMPTY_SET = new EmptySet();
        UNMODIFIABLE_EMPTY_SET = unmodifiable(new BooleanArraySet(BooleanArrays.EMPTY_ARRAY));
    }
    
    public static class EmptySet extends BooleanCollections.EmptyCollection implements BooleanSet, Serializable, Cloneable
    {
        private static final long serialVersionUID = -7046029254386353129L;
        
        protected EmptySet() {
        }
        
        @Override
        public boolean remove(final boolean ok) {
            throw new UnsupportedOperationException();
        }
        
        public Object clone() {
            return BooleanSets.EMPTY_SET;
        }
        
        @Override
        public boolean equals(final Object o) {
            return o instanceof Set && ((Set)o).isEmpty();
        }
        
        @Deprecated
        @Override
        public boolean rem(final boolean k) {
            return super.rem(k);
        }
        
        private Object readResolve() {
            return BooleanSets.EMPTY_SET;
        }
    }
    
    public static class Singleton extends AbstractBooleanSet implements Serializable, Cloneable
    {
        private static final long serialVersionUID = -7046029254386353129L;
        protected final boolean element;
        
        protected Singleton(final boolean element) {
            this.element = element;
        }
        
        @Override
        public boolean contains(final boolean k) {
            return k == this.element;
        }
        
        @Override
        public boolean remove(final boolean k) {
            throw new UnsupportedOperationException();
        }
        
        @Override
        public BooleanListIterator iterator() {
            return BooleanIterators.singleton(this.element);
        }
        
        @Override
        public BooleanSpliterator spliterator() {
            return BooleanSpliterators.singleton(this.element);
        }
        
        @Override
        public int size() {
            return 1;
        }
        
        @Override
        public boolean[] toBooleanArray() {
            return new boolean[] { this.element };
        }
        
        @Deprecated
        @Override
        public void forEach(final Consumer<? super Boolean> action) {
            action.accept(this.element);
        }
        
        @Override
        public boolean addAll(final Collection<? extends Boolean> c) {
            throw new UnsupportedOperationException();
        }
        
        @Override
        public boolean removeAll(final Collection<?> c) {
            throw new UnsupportedOperationException();
        }
        
        @Override
        public boolean retainAll(final Collection<?> c) {
            throw new UnsupportedOperationException();
        }
        
        @Deprecated
        @Override
        public boolean removeIf(final Predicate<? super Boolean> filter) {
            throw new UnsupportedOperationException();
        }
        
        @Override
        public void forEach(final BooleanConsumer action) {
            action.accept(this.element);
        }
        
        @Override
        public boolean addAll(final BooleanCollection c) {
            throw new UnsupportedOperationException();
        }
        
        @Override
        public boolean removeAll(final BooleanCollection c) {
            throw new UnsupportedOperationException();
        }
        
        @Override
        public boolean retainAll(final BooleanCollection c) {
            throw new UnsupportedOperationException();
        }
        
        @Override
        public boolean removeIf(final BooleanPredicate filter) {
            throw new UnsupportedOperationException();
        }
        
        @Deprecated
        @Override
        public Object[] toArray() {
            return new Object[] { this.element };
        }
        
        public Object clone() {
            return this;
        }
    }
    
    public static class SynchronizedSet extends BooleanCollections.SynchronizedCollection implements BooleanSet, Serializable
    {
        private static final long serialVersionUID = -7046029254386353129L;
        
        protected SynchronizedSet(final BooleanSet s, final Object sync) {
            super(s, sync);
        }
        
        protected SynchronizedSet(final BooleanSet s) {
            super(s);
        }
        
        @Override
        public boolean remove(final boolean k) {
            synchronized (this.sync) {
                return this.collection.rem(k);
            }
        }
        
        @Deprecated
        @Override
        public boolean rem(final boolean k) {
            return super.rem(k);
        }
    }
    
    public static class UnmodifiableSet extends BooleanCollections.UnmodifiableCollection implements BooleanSet, Serializable
    {
        private static final long serialVersionUID = -7046029254386353129L;
        
        protected UnmodifiableSet(final BooleanSet s) {
            super(s);
        }
        
        @Override
        public boolean remove(final boolean k) {
            throw new UnsupportedOperationException();
        }
        
        @Override
        public boolean equals(final Object o) {
            return o == this || this.collection.equals(o);
        }
        
        @Override
        public int hashCode() {
            return this.collection.hashCode();
        }
        
        @Deprecated
        @Override
        public boolean rem(final boolean k) {
            return super.rem(k);
        }
    }
}
