Class BytesArray

    • Field Detail

      • a

        public byte[] a
      • n

        public int n
    • Constructor Detail

      • BytesArray

        public BytesArray​(byte[] a)
        For efficiency, does not clone the array arg.
      • BytesArray

        public BytesArray​(int n)
      • BytesArray

        public BytesArray()
      • BytesArray

        public BytesArray​(byte[] a,
                          int n)
        For efficiency, does not clone the array arg.
      • BytesArray

        public BytesArray​(Bytes xs)
        Clones the sequence arg.
      • BytesArray

        public BytesArray​(String s)
    • Method Detail

      • v

        public byte v​(int i)
        Description copied from interface: Bytes
        Value at index i
        Specified by:
        v in interface Bytes
      • n

        public int n()
        Description copied from interface: Bytes
        Length of the sequence
        Specified by:
        n in interface Bytes
      • copyTo

        public void copyTo​(int i,
                           byte[] dest,
                           int iDest,
                           int c)
        Specified by:
        copyTo in interface Bytes
      • copyTo

        public void copyTo​(int i,
                           ByteBuffer dest,
                           int c)
        Specified by:
        copyTo in interface Bytes
      • copyOf

        public byte[] copyOf​(int i,
                             int c)
        Specified by:
        copyOf in interface Bytes
      • copyOf

        public byte[] copyOf()
        Specified by:
        copyOf in interface Bytes
      • string

        public String string​(int i,
                             int c)
        Description copied from interface: Bytes
        Strings are encoded and decoded using the UTF-8 charset (multi-byte charsets just aren't worth the increased complication in indexing). FIXME: This is probably broken, because UTF-8 *is* a multi-byte charset
        Specified by:
        string in interface Bytes
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface Bytes
      • first

        public byte first()
        Specified by:
        first in interface Bytes
      • last

        public byte last()
        Specified by:
        last in interface Bytes
      • set

        public void set​(int i,
                        byte v)
        Specified by:
        set in interface BytesModifiable
      • set

        public void set​(int i,
                        byte[] vs)
        Specified by:
        set in interface BytesModifiable
      • set

        public void set​(int i,
                        byte[] vs,
                        int from,
                        int to)
        Specified by:
        set in interface BytesModifiable
      • insert

        public void insert​(int i,
                           byte[] vs,
                           int from,
                           int to)
        Specified by:
        insert in interface BytesModifiable
      • prepForInsert

        public void prepForInsert​(int i,
                                  int c)
        Makes room in this array for new values to be inserted. When this call returns, the values in this.a on [i,i+c) are undefined. Writing meaningful values to these indices is up to the caller.
        Parameters:
        i - The index at which new values will be inserted
        c - The count of new values that will be inserted
      • prepend

        public void prepend​(byte[] vs,
                            int from,
                            int to)
        Specified by:
        prepend in interface BytesModifiable
      • prepForPrepend

        public void prepForPrepend​(int c)
        Makes room in this array for new values to be prepended. When this call returns, the values in this.a on [0,c) are undefined. Writing meaningful values to these indices is up to the caller.
        Parameters:
        c - The count of new values that will be inserted
      • append

        public void append​(byte[] vs,
                           int from,
                           int to)
        Specified by:
        append in interface BytesModifiable
      • prepForAppend

        public void prepForAppend​(int c)
        Makes room in this array for new values to be appended. When this call returns, the values in this.a on [this.n-c,this.n) are undefined. Writing meaningful values to these indices is up to the caller.
        Parameters:
        c - The count of new values that will be appended
      • remove

        public void remove​(byte v)
        Description copied from interface: BytesModifiable
        Removes a single copy of the specified value. If multiple copies are present, there is no guarantee which one will be removed.
        Specified by:
        remove in interface BytesModifiable
      • removeRange

        public void removeRange​(int from,
                                int to)
        Description copied from interface: BytesModifiable
        Removes values starting at index from (inclusive) to index to (exclusive). All other values with indices greater than or equal to index to have their index in the array decreased by to-from and the size of the array is decreased by to-from.
        Specified by:
        removeRange in interface BytesModifiable
      • removeIndex

        public void removeIndex​(int index)
        Description copied from interface: BytesModifiable
        Remove value at index. All other values with indices greater than index have their index in the array decreased by one and the size of the array is decreased by one.
        Specified by:
        removeIndex in interface BytesModifiable
      • newArray

        public static byte[] newArray​(int oldCapacity,
                                      int minNewCapacity)
        Creates a new array whose capacity is at least minNewCapacity, and at least 1.618 * oldCapacity, up to Integer.MAX_VALUE.