Class ByteList

java.lang.Object
com.mta.tehreer.collections.ByteList
All Implemented Interfaces:
Primitive

public abstract class ByteList extends Object implements Primitive
Represents a primitive list of bytes.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    copyTo(byte[] array, int atIndex)
    Copies all of the bytes in this list to an array, starting at the specified index of the target array.
    boolean
     
    abstract byte
    get(int index)
    Returns the byte at the specified index in this list.
    int
     
    static ByteList
    of(byte... values)
    Returns a byte list whose elements are the specified values.
    abstract int
    Returns the number of bytes in this list.
    abstract ByteList
    subList(int fromIndex, int toIndex)
    Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
    byte[]
    Returns a new array containing all of the bytes in this list in proper sequence (from first to last element).
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ByteList

      public ByteList()
  • Method Details

    • of

      @NonNull public static ByteList of(byte... values)
      Returns a byte list whose elements are the specified values.
      Parameters:
      values - The elements of the byte list.
      Returns:
      A new byte list.
    • size

      public abstract int size()
      Returns the number of bytes in this list.
      Returns:
      The number of bytes in this list.
    • get

      public abstract byte get(int index)
      Returns the byte at the specified index in this list.
      Parameters:
      index - Index of the byte element to return.
      Returns:
      The byte at the specified index in this list.
      Throws:
      IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= size()).
    • copyTo

      public abstract void copyTo(@NonNull byte[] array, int atIndex)
      Copies all of the bytes in this list to an array, starting at the specified index of the target array.
      Parameters:
      array - The array into which the bytes of this list are to be copied.
      atIndex - The index in the target array at which copying begins.
      Throws:
      NullPointerException - if array is null.
      IndexOutOfBoundsException - for an illegal endpoint index value (atIndex < 0 || (array.length - atIndex) < size()).
    • subList

      @NonNull public abstract ByteList subList(int fromIndex, int toIndex)
      Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
      Parameters:
      fromIndex - Low endpoint (inclusive) of the sub list.
      toIndex - High endpoint (exclusive) of the sub list.
      Returns:
      A view of the specified range within this list.
      Throws:
      IndexOutOfBoundsException - for an illegal endpoint index value (fromIndex < 0 || toIndex > size() || fromIndex > toIndex).
    • toArray

      @NonNull public byte[] toArray()
      Returns a new array containing all of the bytes in this list in proper sequence (from first to last element).
      Returns:
      A new array containing all of the bytes in this list in proper sequence.
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      @NonNull public String toString()
      Overrides:
      toString in class Object