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

package it.unimi.dsi.fastutil.longs;

import java.util.Iterator;
import java.util.Collection;
import java.util.Arrays;
import java.util.AbstractCollection;

public abstract class AbstractLongCollection extends AbstractCollection<Long> implements LongCollection
{
    protected AbstractLongCollection() {
    }
    
    @Override
    public abstract LongIterator iterator();
    
    @Override
    public boolean add(final long k) {
        throw new UnsupportedOperationException();
    }
    
    @Override
    public boolean contains(final long k) {
        final LongIterator iterator = this.iterator();
        while (iterator.hasNext()) {
            if (k == iterator.nextLong()) {
                return true;
            }
        }
        return false;
    }
    
    @Override
    public boolean rem(final long k) {
        final LongIterator iterator = this.iterator();
        while (iterator.hasNext()) {
            if (k == iterator.nextLong()) {
                iterator.remove();
                return true;
            }
        }
        return false;
    }
    
    @Deprecated
    @Override
    public boolean add(final Long key) {
        return super.add(key);
    }
    
    @Deprecated
    @Override
    public boolean contains(final Object key) {
        return super.contains(key);
    }
    
    @Deprecated
    @Override
    public boolean remove(final Object key) {
        return super.remove(key);
    }
    
    @Override
    public long[] toArray(long[] a) {
        final int size = this.size();
        if (a == null) {
            a = new long[size];
        }
        else if (a.length < size) {
            a = Arrays.copyOf(a, size);
        }
        LongIterators.unwrap(this.iterator(), a);
        return a;
    }
    
    @Override
    public long[] toLongArray() {
        final int size = this.size();
        if (size == 0) {
            return LongArrays.EMPTY_ARRAY;
        }
        final long[] a = new long[size];
        LongIterators.unwrap(this.iterator(), a);
        return a;
    }
    
    @Deprecated
    @Override
    public long[] toLongArray(final long[] a) {
        return this.toArray(a);
    }
    
    @Override
    public final void forEach(final LongConsumer action) {
        super.forEach(action);
    }
    
    @Override
    public final boolean removeIf(final LongPredicate filter) {
        return super.removeIf(filter);
    }
    
    @Override
    public boolean addAll(final LongCollection c) {
        boolean retVal = false;
        final LongIterator i = c.iterator();
        while (i.hasNext()) {
            if (this.add(i.nextLong())) {
                retVal = true;
            }
        }
        return retVal;
    }
    
    @Override
    public boolean addAll(final Collection<? extends Long> c) {
        if (c instanceof LongCollection) {
            return this.addAll((LongCollection)c);
        }
        return super.addAll(c);
    }
    
    @Override
    public boolean containsAll(final LongCollection c) {
        final LongIterator i = c.iterator();
        while (i.hasNext()) {
            if (!this.contains(i.nextLong())) {
                return false;
            }
        }
        return true;
    }
    
    @Override
    public boolean containsAll(final Collection<?> c) {
        if (c instanceof LongCollection) {
            return this.containsAll((LongCollection)c);
        }
        return super.containsAll(c);
    }
    
    @Override
    public boolean removeAll(final LongCollection c) {
        boolean retVal = false;
        final LongIterator i = c.iterator();
        while (i.hasNext()) {
            if (this.rem(i.nextLong())) {
                retVal = true;
            }
        }
        return retVal;
    }
    
    @Override
    public boolean removeAll(final Collection<?> c) {
        if (c instanceof LongCollection) {
            return this.removeAll((LongCollection)c);
        }
        return super.removeAll(c);
    }
    
    @Override
    public boolean retainAll(final LongCollection c) {
        boolean retVal = false;
        final LongIterator i = this.iterator();
        while (i.hasNext()) {
            if (!c.contains(i.nextLong())) {
                i.remove();
                retVal = true;
            }
        }
        return retVal;
    }
    
    @Override
    public boolean retainAll(final Collection<?> c) {
        if (c instanceof LongCollection) {
            return this.retainAll((LongCollection)c);
        }
        return super.retainAll(c);
    }
    
    @Override
    public String toString() {
        final StringBuilder s = new StringBuilder();
        final LongIterator i = this.iterator();
        int n = this.size();
        boolean first = true;
        s.append("{");
        while (n-- != 0) {
            if (first) {
                first = false;
            }
            else {
                s.append(", ");
            }
            final long k = i.nextLong();
            s.append(String.valueOf(k));
        }
        s.append("}");
        return s.toString();
    }
}
