Class ByteList

    • Constructor Detail

      • ByteList

        public ByteList()
        Instantiates a new byte list.
      • ByteList

        public ByteList​(int initialCapacity)
        Instantiates a new byte list.
        Parameters:
        initialCapacity -
      • ByteList

        public ByteList​(byte[] a)
        The specified array is used as the element array for this list without copying action.
        Parameters:
        a -
      • ByteList

        public ByteList​(byte[] a,
                        int size)
        Instantiates a new byte list.
        Parameters:
        a -
        size -
    • Method Detail

      • of

        public static ByteList of​(byte[] a,
                                  int size)
        Parameters:
        a -
        size -
        Returns:
      • copyOf

        public static ByteList copyOf​(byte[] a)
        Parameters:
        a -
        Returns:
      • copyOf

        public static ByteList copyOf​(byte[] a,
                                      int fromIndex,
                                      int toIndex)
        Parameters:
        a -
        fromIndex -
        toIndex -
        Returns:
      • from

        public static ByteList from​(Collection<Byte> c,
                                    byte defaultForNull)
        Parameters:
        c -
        defaultForNull -
        Returns:
      • from

        public static ByteList from​(Collection<Byte> c,
                                    int fromIndex,
                                    int toIndex)
        Parameters:
        c -
        fromIndex -
        toIndex -
        Returns:
      • from

        public static ByteList from​(Collection<Byte> c,
                                    int fromIndex,
                                    int toIndex,
                                    byte defaultForNull)
        Parameters:
        c -
        fromIndex -
        toIndex -
        defaultForNull -
        Returns:
      • range

        public static ByteList range​(byte startInclusive,
                                     byte endExclusive)
        Parameters:
        startInclusive -
        endExclusive -
        Returns:
      • range

        public static ByteList range​(byte startInclusive,
                                     byte endExclusive,
                                     byte by)
        Parameters:
        startInclusive -
        endExclusive -
        by -
        Returns:
      • rangeClosed

        public static ByteList rangeClosed​(byte startInclusive,
                                           byte endInclusive)
        Parameters:
        startInclusive -
        endInclusive -
        Returns:
      • rangeClosed

        public static ByteList rangeClosed​(byte startInclusive,
                                           byte endInclusive,
                                           byte by)
        Parameters:
        startInclusive -
        endInclusive -
        by -
        Returns:
      • repeat

        public static ByteList repeat​(byte element,
                                      int len)
        Parameters:
        element -
        len -
        Returns:
      • random

        public static ByteList random​(int len)
        Parameters:
        len -
        Returns:
      • array

        public byte[] array()
        Returns the original element array without copying.
        Specified by:
        array in class PrimitiveList<Byte,​byte[],​ByteList>
        Returns:
      • get

        public byte get​(int index)
        Parameters:
        index -
        Returns:
      • set

        public byte set​(int index,
                        byte e)
        Parameters:
        index -
        e -
        Returns:
      • add

        public void add​(byte e)
        Parameters:
        e -
      • add

        public void add​(int index,
                        byte e)
        Parameters:
        index -
        e -
      • addAll

        public boolean addAll​(ByteList c)
        Adds the all.
        Parameters:
        c -
        Returns:
        true, if successful
      • addAll

        public boolean addAll​(int index,
                              ByteList c)
        Adds the all.
        Parameters:
        index -
        c -
        Returns:
        true, if successful
      • addAll

        public boolean addAll​(byte[] a)
        Adds the all.
        Specified by:
        addAll in class PrimitiveList<Byte,​byte[],​ByteList>
        Parameters:
        a -
        Returns:
        true, if successful
      • addAll

        public boolean addAll​(int index,
                              byte[] a)
        Adds the all.
        Specified by:
        addAll in class PrimitiveList<Byte,​byte[],​ByteList>
        Parameters:
        index -
        a -
        Returns:
        true, if successful
      • remove

        public boolean remove​(byte e)
        Parameters:
        e -
        Returns:
        true if this list contained the specified element
      • removeAllOccurrences

        public boolean removeAllOccurrences​(byte e)
        Removes the all occurrences.
        Parameters:
        e -
        Returns:
        true if this list contained the specified element
      • removeAll

        public boolean removeAll​(ByteList c)
        Removes the all.
        Parameters:
        c -
        Returns:
        true, if successful
      • removeAll

        public boolean removeAll​(byte[] a)
        Removes the all.
        Specified by:
        removeAll in class PrimitiveList<Byte,​byte[],​ByteList>
        Parameters:
        a -
        Returns:
        true, if successful
      • retainAll

        public boolean retainAll​(ByteList c)
        Parameters:
        c -
        Returns:
        true, if successful
      • retainAll

        public boolean retainAll​(byte[] a)
        Parameters:
        a -
        Returns:
        true, if successful
      • delete

        public byte delete​(int index)
        Parameters:
        index -
        Returns:
      • deleteRange

        public void deleteRange​(int fromIndex,
                                int toIndex)
        Specified by:
        deleteRange in class PrimitiveList<Byte,​byte[],​ByteList>
        Parameters:
        fromIndex -
        toIndex -
      • replaceAll

        public int replaceAll​(byte oldVal,
                              byte newVal)
        Parameters:
        oldVal -
        newVal -
        Returns:
      • replaceIf

        public <E extends Exception> boolean replaceIf​(Throwables.BytePredicate<E> predicate,
                                                       byte newValue)
                                                throws E extends Exception
        Type Parameters:
        E -
        Parameters:
        predicate -
        newValue -
        Returns:
        true, if successful
        Throws:
        E - the e
        E extends Exception
      • fill

        public void fill​(byte val)
        Parameters:
        val -
      • fill

        public void fill​(int fromIndex,
                         int toIndex,
                         byte val)
        Parameters:
        fromIndex -
        toIndex -
        val -
      • contains

        public boolean contains​(byte e)
        Parameters:
        e -
        Returns:
        true, if successful
      • containsAll

        public boolean containsAll​(ByteList c)
        Parameters:
        c -
        Returns:
        true, if successful
      • containsAll

        public boolean containsAll​(byte[] a)
        Specified by:
        containsAll in class PrimitiveList<Byte,​byte[],​ByteList>
        Parameters:
        a -
        Returns:
        true, if successful
      • containsAny

        public boolean containsAny​(ByteList c)
        Parameters:
        c -
        Returns:
        true, if successful
      • containsAny

        public boolean containsAny​(byte[] a)
        Specified by:
        containsAny in class PrimitiveList<Byte,​byte[],​ByteList>
        Parameters:
        a -
        Returns:
        true, if successful
      • disjoint

        public boolean disjoint​(ByteList c)
        Parameters:
        c -
        Returns:
        true, if successful
      • disjoint

        public boolean disjoint​(byte[] b)
        Specified by:
        disjoint in class PrimitiveList<Byte,​byte[],​ByteList>
        Parameters:
        b -
        Returns:
        true, if successful
      • intersection

        public ByteList intersection​(byte[] a)
        Parameters:
        a -
        Returns:
      • difference

        public ByteList difference​(byte[] a)
        Parameters:
        a -
        Returns:
      • symmetricDifference

        public ByteList symmetricDifference​(byte[] a)
        Parameters:
        a -
        Returns:
      • occurrencesOf

        public int occurrencesOf​(byte objectToFind)
        Parameters:
        objectToFind -
        Returns:
      • indexOf

        public int indexOf​(byte e)
        Parameters:
        e -
        Returns:
      • indexOf

        public int indexOf​(int fromIndex,
                           byte e)
        Parameters:
        fromIndex -
        e -
        Returns:
      • lastIndexOf

        public int lastIndexOf​(byte e)
        Last index of.
        Parameters:
        e -
        Returns:
      • lastIndexOf

        public int lastIndexOf​(int fromIndex,
                               byte e)
        Last index of.
        Parameters:
        fromIndex - the start index to traverse backwards from. Inclusive.
        e -
        Returns:
      • min

        public u.OptionalByte min​(int fromIndex,
                                  int toIndex)
        Parameters:
        fromIndex -
        toIndex -
        Returns:
      • median

        public u.OptionalByte median​(int fromIndex,
                                     int toIndex)
        Parameters:
        fromIndex -
        toIndex -
        Returns:
      • max

        public u.OptionalByte max​(int fromIndex,
                                  int toIndex)
        Parameters:
        fromIndex -
        toIndex -
        Returns:
      • kthLargest

        public u.OptionalByte kthLargest​(int k)
        Parameters:
        k -
        Returns:
      • kthLargest

        public u.OptionalByte kthLargest​(int fromIndex,
                                         int toIndex,
                                         int k)
        Parameters:
        fromIndex -
        toIndex -
        k -
        Returns:
      • sum

        public int sum()
        Returns:
      • sum

        public int sum​(int fromIndex,
                       int toIndex)
        Parameters:
        fromIndex -
        toIndex -
        Returns:
      • average

        public u.OptionalDouble average​(int fromIndex,
                                        int toIndex)
        Parameters:
        fromIndex -
        toIndex -
        Returns:
      • forEach

        public <E extends Exception> void forEach​(int fromIndex,
                                                  int toIndex,
                                                  Throwables.ByteConsumer<E> action)
                                           throws E extends Exception
        Type Parameters:
        E -
        Parameters:
        fromIndex -
        toIndex -
        action -
        Throws:
        E - the e
        E extends Exception
      • allMatch

        public <E extends Exception> boolean allMatch​(Throwables.BytePredicate<E> filter)
                                               throws E extends Exception
        Returns whether all elements of this List match the provided predicate.
        Type Parameters:
        E -
        Parameters:
        filter -
        Returns:
        true, if successful
        Throws:
        E - the e
        E extends Exception
      • allMatch

        public <E extends Exception> boolean allMatch​(int fromIndex,
                                                      int toIndex,
                                                      Throwables.BytePredicate<E> filter)
                                               throws E extends Exception
        Type Parameters:
        E -
        Parameters:
        fromIndex -
        toIndex -
        filter -
        Returns:
        true, if successful
        Throws:
        E - the e
        E extends Exception
      • anyMatch

        public <E extends Exception> boolean anyMatch​(Throwables.BytePredicate<E> filter)
                                               throws E extends Exception
        Returns whether any elements of this List match the provided predicate.
        Type Parameters:
        E -
        Parameters:
        filter -
        Returns:
        true, if successful
        Throws:
        E - the e
        E extends Exception
      • anyMatch

        public <E extends Exception> boolean anyMatch​(int fromIndex,
                                                      int toIndex,
                                                      Throwables.BytePredicate<E> filter)
                                               throws E extends Exception
        Type Parameters:
        E -
        Parameters:
        fromIndex -
        toIndex -
        filter -
        Returns:
        true, if successful
        Throws:
        E - the e
        E extends Exception
      • noneMatch

        public <E extends Exception> boolean noneMatch​(Throwables.BytePredicate<E> filter)
                                                throws E extends Exception
        Returns whether no elements of this List match the provided predicate.
        Type Parameters:
        E -
        Parameters:
        filter -
        Returns:
        true, if successful
        Throws:
        E - the e
        E extends Exception
      • noneMatch

        public <E extends Exception> boolean noneMatch​(int fromIndex,
                                                       int toIndex,
                                                       Throwables.BytePredicate<E> filter)
                                                throws E extends Exception
        Type Parameters:
        E -
        Parameters:
        fromIndex -
        toIndex -
        filter -
        Returns:
        true, if successful
        Throws:
        E - the e
        E extends Exception
      • count

        public <E extends Exception> int count​(int fromIndex,
                                               int toIndex,
                                               Throwables.BytePredicate<E> filter)
                                        throws E extends Exception
        Type Parameters:
        E -
        Parameters:
        fromIndex -
        toIndex -
        filter -
        Returns:
        Throws:
        E - the e
        E extends Exception
      • mapToObj

        public <T,​E extends ExceptionList<T> mapToObj​(int fromIndex,
                                                              int toIndex,
                                                              Throwables.ByteFunction<? extends T,​E> mapper)
                                                       throws E extends Exception
        Map to obj.
        Type Parameters:
        T -
        E -
        Parameters:
        fromIndex -
        toIndex -
        mapper -
        Returns:
        Throws:
        E - the e
        E extends Exception
      • reduce

        public <E extends Exceptionu.OptionalByte reduce​(Throwables.ByteBinaryOperator<E> accumulator)
                                                    throws E extends Exception
        This is equivalent to:
         
            if (isEmpty()) {
                return OptionalByte.empty();
            }
        
            byte result = elementData[0];
        
            for (int i = 1; i < size; i++) {
                result = accumulator.applyAsByte(result, elementData[i]);
            }
        
            return OptionalByte.of(result);
         
         
        Type Parameters:
        E -
        Parameters:
        accumulator -
        Returns:
        Throws:
        E - the e
        E extends Exception
      • reduce

        public <E extends Exception> byte reduce​(byte identity,
                                                 Throwables.ByteBinaryOperator<E> accumulator)
                                          throws E extends Exception
        This is equivalent to:
         
             if (isEmpty()) {
                 return identity;
             }
        
             byte result = identity;
        
             for (int i = 0; i < size; i++) {
                 result = accumulator.applyAsByte(result, elementData[i]);
            }
        
             return result;
         
         
        Type Parameters:
        E -
        Parameters:
        identity -
        accumulator -
        Returns:
        Throws:
        E - the e
        E extends Exception
      • parallelSort

        public void parallelSort()
        Parallel sort.
      • reverseSort

        public void reverseSort()
        Reverse sort.
      • binarySearch

        public int binarySearch​(byte key)
        This List should be sorted first.
        Parameters:
        key -
        Returns:
      • binarySearch

        public int binarySearch​(int fromIndex,
                                int toIndex,
                                byte key)
        This List should be sorted first.
        Parameters:
        fromIndex -
        toIndex -
        key -
        Returns:
      • reverse

        public void reverse​(int fromIndex,
                            int toIndex)
        Specified by:
        reverse in class PrimitiveList<Byte,​byte[],​ByteList>
        Parameters:
        fromIndex -
        toIndex -
      • copy

        public ByteList copy​(int from,
                             int to,
                             int step)
        Specified by:
        copy in class PrimitiveList<Byte,​byte[],​ByteList>
        Parameters:
        from -
        to -
        step -
        Returns:
        See Also:
        CommonUtil.copyOfRange(int[], int, int, int)
      • split

        public List<ByteList> split​(int fromIndex,
                                    int toIndex,
                                    int chunkSize)
        Returns List of ByteList with consecutive sub sequences of the elements, each of the same size (the final sequence may be smaller).
        Specified by:
        split in class PrimitiveList<Byte,​byte[],​ByteList>
        Parameters:
        fromIndex -
        toIndex -
        chunkSize - the desired size of each sub sequence (the last may be smaller).
        Returns:
      • join

        public String join​(int fromIndex,
                           int toIndex,
                           char delimiter)
        Specified by:
        join in class PrimitiveList<Byte,​byte[],​ByteList>
        Parameters:
        fromIndex -
        toIndex -
        delimiter -
        Returns:
      • join

        public String join​(int fromIndex,
                           int toIndex,
                           String delimiter)
        Specified by:
        join in class PrimitiveList<Byte,​byte[],​ByteList>
        Parameters:
        fromIndex -
        toIndex -
        delimiter -
        Returns:
      • boxed

        public List<Byte> boxed()
        Returns:
      • boxed

        public List<Byte> boxed​(int fromIndex,
                                int toIndex)
        Parameters:
        fromIndex -
        toIndex -
        Returns:
      • toIntList

        public IntList toIntList()
        To int list.
        Returns:
      • toMap

        public <K,​A,​D,​M extends Map<K,​D>,​E extends Exception> M toMap​(Throwables.ByteFunction<? extends K,​E> keyMapper,
                                                                                                    Collector<Byte,​A,​D> downstream,
                                                                                                    IntFunction<? extends M> mapFactory)
                                                                                             throws E extends Exception
        Type Parameters:
        K - the key type
        A -
        D -
        M -
        E -
        Parameters:
        keyMapper -
        downstream -
        mapFactory -
        Returns:
        Throws:
        E - the e
        E extends Exception
      • stream

        public ByteStream stream​(int fromIndex,
                                 int toIndex)
        Parameters:
        fromIndex -
        toIndex -
        Returns:
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
        Returns:
      • equals

        public boolean equals​(Object obj)
        Overrides:
        equals in class Object
        Parameters:
        obj -
        Returns:
        true, if successful