Package io.datarouter.bytes
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 Summary
Fields Modifier and Type Field Description protected byte[]backingArrayprotected int[]endingsprotected intoffsetprotected intvaluesOffsetFields inherited from class java.util.AbstractList
modCount -
Constructor Summary
Constructors Modifier Constructor Description protectedByteArrays(byte[] backingArray, int offset)protectedByteArrays(List<byte[]> items) -
Method Summary
Modifier and Type Method Description intcompareItem(int index, byte[] target)static intcompareItem(ByteArrays arrays1, int index1, ByteArrays arrays2, int index2)booleancontains(Object other)static ByteArraysempty()protected booleanequalsItem(int index, byte[] target)byte[]get(int index)protected intgetFrom(int index)intgetLength()Number of bytes spanned in the backingArrayprotected intgetTo(int index)static ByteArraysof(byte[] backingArray, int offset)static ByteArraysof(List<byte[]> inputArrays)intsize()byte[]toBytes()Returns the backingArray directly if possible, otherwise a copy of the relevant range of bytesMethods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subListMethods inherited from class java.util.AbstractCollection
addAll, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addAll, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
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
-
ByteArrays
protected ByteArrays(byte[] backingArray, int offset)
-
-
Method Details
-
empty
-
of
-
of
-
contains
- Specified by:
containsin interfaceCollection<byte[]>- Specified by:
containsin interfaceList<byte[]>- Overrides:
containsin classAbstractCollection<byte[]>
-
get
public byte[] get(int index)- Specified by:
getin interfaceList<byte[]>- Specified by:
getin classAbstractList<byte[]>
-
size
public int size()- Specified by:
sizein interfaceCollection<byte[]>- Specified by:
sizein interfaceList<byte[]>- Specified by:
sizein classAbstractCollection<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
-
equalsItem
protected boolean equalsItem(int index, byte[] target)
-