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

package it.unimi.dsi.fastutil.bytes;

import java.util.Iterator;
import java.util.ListIterator;
import java.util.Spliterator;
import java.util.Comparator;
import java.util.Objects;
import java.util.function.UnaryOperator;
import it.unimi.dsi.fastutil.SafeMath;
import java.util.function.IntUnaryOperator;
import java.util.Collection;
import it.unimi.dsi.fastutil.Size64;
import java.util.RandomAccess;
import java.util.List;

public interface ByteList extends List<Byte>, Comparable<List<? extends Byte>>, ByteCollection
{
    ByteListIterator iterator();
    
    default ByteSpliterator spliterator() {
        if (this instanceof RandomAccess) {
            return new AbstractByteList.IndexBasedSpliterator(this, 0);
        }
        return ByteSpliterators.asSpliterator(this.iterator(), Size64.sizeOf(this), 16720);
    }
    
    ByteListIterator listIterator();
    
    ByteListIterator listIterator(final int p0);
    
    ByteList subList(final int p0, final int p1);
    
    void size(final int p0);
    
    void getElements(final int p0, final byte[] p1, final int p2, final int p3);
    
    void removeElements(final int p0, final int p1);
    
    void addElements(final int p0, final byte[] p1);
    
    void addElements(final int p0, final byte[] p1, final int p2, final int p3);
    
    default void setElements(final byte[] a) {
        this.setElements(0, a);
    }
    
    default void setElements(final int index, final byte[] a) {
        this.setElements(index, a, 0, a.length);
    }
    
    default void setElements(final int index, final byte[] a, final int offset, final int length) {
        if (index < 0) {
            throw new IndexOutOfBoundsException("Index (" + index + ") is negative");
        }
        if (index > this.size()) {
            throw new IndexOutOfBoundsException("Index (" + index + ") is greater than list size (" + this.size() + ")");
        }
        ByteArrays.ensureOffsetLength(a, offset, length);
        if (index + length > this.size()) {
            throw new IndexOutOfBoundsException("End index (" + (index + length) + ") is greater than list size (" + this.size() + ")");
        }
        final ByteListIterator iter = this.listIterator(index);
        int i = 0;
        while (i < length) {
            iter.nextByte();
            iter.set(a[offset + i++]);
        }
    }
    
    boolean add(final byte p0);
    
    void add(final int p0, final byte p1);
    
    @Deprecated
    default void add(final int index, final Byte key) {
        this.add(index, (byte)key);
    }
    
    boolean addAll(final int p0, final ByteCollection p1);
    
    byte set(final int p0, final byte p1);
    
    default void replaceAll(final ByteUnaryOperator operator) {
        final ByteListIterator iter = this.listIterator();
        while (iter.hasNext()) {
            iter.set(operator.apply(iter.nextByte()));
        }
    }
    
    default void replaceAll(final IntUnaryOperator operator) {
        this.replaceAll((operator instanceof ByteUnaryOperator) ? ((ByteUnaryOperator)operator) : (x -> SafeMath.safeIntToByte(operator.applyAsInt(x))));
    }
    
    @Deprecated
    default void replaceAll(final UnaryOperator<Byte> operator) {
        Objects.requireNonNull(operator);
        ByteUnaryOperator operator2;
        if (operator instanceof ByteUnaryOperator) {
            operator2 = (ByteUnaryOperator)operator;
        }
        else {
            Objects.requireNonNull(operator);
            operator2 = operator::apply;
        }
        this.replaceAll(operator2);
    }
    
    byte getByte(final int p0);
    
    int indexOf(final byte p0);
    
    int lastIndexOf(final byte p0);
    
    @Deprecated
    default boolean contains(final Object key) {
        return super.contains(key);
    }
    
    @Deprecated
    default Byte get(final int index) {
        return this.getByte(index);
    }
    
    @Deprecated
    default int indexOf(final Object o) {
        return this.indexOf((byte)o);
    }
    
    @Deprecated
    default int lastIndexOf(final Object o) {
        return this.lastIndexOf((byte)o);
    }
    
    @Deprecated
    default boolean add(final Byte k) {
        return this.add((byte)k);
    }
    
    byte removeByte(final int p0);
    
    @Deprecated
    default boolean remove(final Object key) {
        return super.remove(key);
    }
    
    @Deprecated
    default Byte remove(final int index) {
        return this.removeByte(index);
    }
    
    @Deprecated
    default Byte set(final int index, final Byte k) {
        return this.set(index, (byte)k);
    }
    
    default boolean addAll(final int index, final ByteList l) {
        return this.addAll(index, (ByteCollection)l);
    }
    
    default boolean addAll(final ByteList l) {
        return this.addAll(this.size(), l);
    }
    
    default ByteList of() {
        return ByteImmutableList.of();
    }
    
    default ByteList of(final byte e) {
        return ByteLists.singleton(e);
    }
    
    default ByteList of(final byte e0, final byte e1) {
        return ByteImmutableList.of(new byte[] { e0, e1 });
    }
    
    default ByteList of(final byte e0, final byte e1, final byte e2) {
        return ByteImmutableList.of(new byte[] { e0, e1, e2 });
    }
    
    default ByteList of(final byte... a) {
        switch (a.length) {
            case 0: {
                return of();
            }
            case 1: {
                return of(a[0]);
            }
            default: {
                return ByteImmutableList.of(a);
            }
        }
    }
    
    @Deprecated
    default void sort(final Comparator<? super Byte> comparator) {
        this.sort(ByteComparators.asByteComparator(comparator));
    }
    
    default void sort(final ByteComparator comparator) {
        if (comparator == null) {
            this.unstableSort(comparator);
        }
        else {
            final byte[] elements = this.toByteArray();
            ByteArrays.stableSort(elements, comparator);
            this.setElements(elements);
        }
    }
    
    @Deprecated
    default void unstableSort(final Comparator<? super Byte> comparator) {
        this.unstableSort(ByteComparators.asByteComparator(comparator));
    }
    
    default void unstableSort(final ByteComparator comparator) {
        final byte[] elements = this.toByteArray();
        if (comparator == null) {
            ByteArrays.unstableSort(elements);
        }
        else {
            ByteArrays.unstableSort(elements, comparator);
        }
        this.setElements(elements);
    }
}
