Class ByteArrays

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<byte[]>
io.datarouter.bytes.ByteArrays
All Implemented Interfaces:
Iterable<byte[]>, Collection<byte[]>, List<byte[]>, RandomAccess
Direct Known Subclasses:
SortedByteArrays

public class ByteArrays
extends AbstractList<byte[]>
implements RandomAccess
Concatenated List of byte arrays with RandomAccess
  • Field Details

    • backingArray

      protected final byte[] backingArray
    • offset

      protected final int offset
    • valuesOffset

      protected final int valuesOffset
    • endings

      protected final int[] endings
  • Constructor Details

    • ByteArrays

      protected ByteArrays​(List<byte[]> items)
    • ByteArrays

      protected ByteArrays​(byte[] backingArray, int offset)
  • Method Details

    • empty

      public static ByteArrays empty()
    • of

      public static ByteArrays of​(List<byte[]> inputArrays)
    • of

      public static ByteArrays of​(byte[] backingArray, int offset)
    • contains

      public boolean contains​(Object other)
      Specified by:
      contains in interface Collection<byte[]>
      Specified by:
      contains in interface List<byte[]>
      Overrides:
      contains in class AbstractCollection<byte[]>
    • get

      public byte[] get​(int index)
      Specified by:
      get in interface List<byte[]>
      Specified by:
      get in class AbstractList<byte[]>
    • size

      public int size()
      Specified by:
      size in interface Collection<byte[]>
      Specified by:
      size in interface List<byte[]>
      Specified by:
      size in class AbstractCollection<byte[]>
    • getLength

      public int getLength()
      Number of bytes spanned in the backingArray
    • toBytes

      public byte[] toBytes()
      Returns the backingArray directly if possible, otherwise a copy of the relevant range of bytes
    • getFrom

      protected int getFrom​(int index)
    • getTo

      protected int getTo​(int index)
    • compareItem

      public int compareItem​(int index, byte[] target)
    • compareItem

      public static int compareItem​(ByteArrays arrays1, int index1, ByteArrays arrays2, int index2)
    • equalsItem

      protected boolean equalsItem​(int index, byte[] target)