Class ByteArrayList
- java.lang.Object
-
- org.eclipse.collections.impl.primitive.AbstractByteIterable
-
- org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,ByteIterable,MutableByteCollection,ByteList,MutableByteList,OrderedByteIterable,ReversibleByteIterable,PrimitiveIterable
public class ByteArrayList extends AbstractByteIterable implements MutableByteList, java.io.Externalizable
ByteArrayList is similar to FastList, and is memory-optimized for byte primitives. This file was automatically generated from template file primitiveArrayList.stg.- Since:
- 3.0.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classByteArrayList.InternalByteIterator
-
Field Summary
Fields Modifier and Type Field Description private static byte[]DEFAULT_SIZED_EMPTY_ARRAYprotected byte[]itemsprivate static intMAXIMUM_ARRAY_SIZEprivate static longserialVersionUIDprotected intsizeprivate static byte[]ZERO_SIZED_ARRAY
-
Constructor Summary
Constructors Constructor Description ByteArrayList()ByteArrayList(byte... array)ByteArrayList(int initialCapacity)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(byte newItem)booleanaddAll(byte... source)booleanaddAll(ByteIterable source)booleanaddAllAtIndex(int index, byte... source)booleanaddAllAtIndex(int index, ByteIterable source)voidaddAtIndex(int index, byte element)private voidaddAtIndexLessThanSize(int index, byte element)booleanallSatisfy(BytePredicate predicate)Returns true if all of the elements in the ByteIterable return true for the specified predicate, otherwise returns false.booleananySatisfy(BytePredicate predicate)Returns true if any of the elements in the ByteIterable return true for the specified predicate, otherwise returns false.voidappendString(java.lang.Appendable appendable, java.lang.String start, java.lang.String separator, java.lang.String end)Prints a string representation of this collection onto the givenAppendable.LazyByteIterableasReversed()MutableByteListasSynchronized()MutableByteListasUnmodifiable()intbinarySearch(byte value)MutableList<java.lang.Byte>boxed()MutableByteIteratorbyteIterator()Returns a primitive iterator that can be used to iterate over the ByteIterable in an imperative style.private voidcheckEmpty()RichIterable<ByteIterable>chunk(int size)Partitions elements in fixed size chunks.voidclear()<V> MutableList<V>collect(ByteToObjectFunction<? extends V> function)Returns a new collection with the results of applying the specified function on each element of the source collection.<V,R extends java.util.Collection<V>>
Rcollect(ByteToObjectFunction<? extends V> function, R target)Same asByteIterable.collect(ByteToObjectFunction), only the results are added to the target Collection.booleancontains(byte value)Returns true if the value is contained in the ByteIterable, and false if it is not.private voidcopyItems(int sourceSize, byte[] source)private byte[]copyItemsWithNewCapacity(int newCapacity)intcount(BytePredicate predicate)Returns a count of the number of elements in the ByteIterable that return true for the specified predicate.bytedetectIfNone(BytePredicate predicate, byte ifNone)MutableByteListdistinct()longdotProduct(ByteList list)voideach(ByteProcedure procedure)A synonym for forEach.voidensureCapacity(int minCapacity)private voidensureCapacityForAdd()booleanequals(java.lang.Object otherList)Follows the same general contract asList.equals(Object).voidforEachWithIndex(ByteIntProcedure procedure)byteget(int index)bytegetFirst()bytegetLast()inthashCode()Follows the same general contract asList.hashCode().intindexOf(byte value)<T> TinjectInto(T injectedValue, ObjectByteToObjectFunction<? super T,? extends T> function)<T> TinjectIntoWithIndex(T injectedValue, ObjectByteIntToObjectFunction<? super T,? extends T> function)intlastIndexOf(byte value)bytemax()bytemin()ByteArrayListnewEmpty()Creates a new empty ByteArrayList.private java.lang.IndexOutOfBoundsExceptionnewIndexOutOfBoundsException(int index)static ByteArrayListnewList(ByteIterable source)static ByteArrayListnewListWith(byte... elements)Creates a new list using the passedelementsargument as the backing store.static ByteArrayListnewWithNValues(int size, byte value)voidreadExternal(java.io.ObjectInput in)ByteArrayListreject(BytePredicate predicate)Returns a new ByteIterable with all of the elements in the ByteIterable that return false for the specified predicate.<R extends MutableByteCollection>
Rreject(BytePredicate predicate, R target)Same asByteIterable.reject(BytePredicate), only the results are added to the target MutableByteCollection.booleanremove(byte value)booleanremoveAll(byte... source)booleanremoveAll(ByteIterable source)byteremoveAtIndex(int index)booleanremoveIf(BytePredicate predicate)booleanretainAll(byte... source)booleanretainAll(ByteIterable source)ByteArrayListreverseThis()ByteArrayListselect(BytePredicate predicate)Returns a new ByteIterable with all of the elements in the ByteIterable that return true for the specified predicate.<R extends MutableByteCollection>
Rselect(BytePredicate predicate, R target)Same asByteIterable.select(BytePredicate), only the results are added to the target MutableByteCollection.byteset(int index, byte element)private voidshiftElementsAtIndex(int index, int sourceSize)intsize()Returns the number of items in this iterable.private intsizePlusFiftyPercent(int oldSize)ByteArrayListsortThis()Sorts this list mutating its contents and returns the same mutable list (this).ByteArrayListsortThis(ByteComparator comparator)Sorts the internal data structure of this list and returns the list itself as a convenience.MutableByteListsubList(int fromIndex, int toIndex)longsum()voidswap(int index1, int index2)private voidthrowOutOfBounds(int index)byte[]toArray()Converts the ByteIterable to a primitive byte array.byte[]toArray(byte[] target)Converts the ByteIterable to a primitive byte array.ImmutableByteListtoImmutable()Returns an immutable copy of this list.ByteArrayListtoReversed()MutableByteStacktoStack()Converts the collection to a ByteStack.private voidtransferItemsToNewArrayWithCapacity(int newCapacity)voidtrimToSize()private voidwipeAndResetTheEnd(int newCurrentFilledIndex)ByteArrayListwith(byte element)ByteArrayListwith(byte element1, byte element2)ByteArrayListwith(byte element1, byte element2, byte element3)ByteArrayListwith(byte element1, byte element2, byte element3, byte... elements)ByteArrayListwithAll(ByteIterable elements)private ByteArrayListwithArrayCopy(byte[] elements, int begin, int length)ByteArrayListwithout(byte element)ByteArrayListwithoutAll(ByteIterable elements)static ByteArrayListwrapCopy(byte... array)Creates a new list by first copying the array passed in.voidwriteExternal(java.io.ObjectOutput out)<T> MutableList<ByteObjectPair<T>>zip(java.lang.Iterable<T> iterable)Returns aMutableListformed from thisMutableByteListand aListIterableby combining corresponding elements in pairs.MutableList<ByteBytePair>zipByte(ByteIterable iterable)Returns aMutableListformed from thisMutableByteListand anotherByteListby combining corresponding elements in pairs.-
Methods inherited from class org.eclipse.collections.impl.primitive.AbstractByteIterable
asLazy, average, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.collections.api.ByteIterable
asLazy, average, averageIfEmpty, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, containsAll, containsAll, containsAny, containsAny, containsNone, containsNone, flatCollect, forEach, injectIntoBoolean, injectIntoByte, injectIntoChar, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, injectIntoShort, maxIfEmpty, median, medianIfEmpty, minIfEmpty, noneSatisfy, reduce, reduceIfEmpty, summaryStatistics, toBag, toList, toSet, toSortedArray, toSortedList, toSortedList, toSortedListBy, toSortedListBy
-
Methods inherited from interface org.eclipse.collections.api.list.primitive.ByteList
forEachInBoth
-
Methods inherited from interface org.eclipse.collections.api.list.primitive.MutableByteList
collectWithIndex, rejectWithIndex, selectWithIndex, shuffleThis, shuffleThis, sortThisBy, sortThisBy, tap
-
Methods inherited from interface org.eclipse.collections.api.ordered.primitive.OrderedByteIterable
collectWithIndex, rejectWithIndex, selectWithIndex
-
Methods inherited from interface org.eclipse.collections.api.PrimitiveIterable
appendString, appendString, isEmpty, makeString, makeString, makeString, notEmpty, toString
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
DEFAULT_SIZED_EMPTY_ARRAY
private static final byte[] DEFAULT_SIZED_EMPTY_ARRAY
-
ZERO_SIZED_ARRAY
private static final byte[] ZERO_SIZED_ARRAY
-
MAXIMUM_ARRAY_SIZE
private static final int MAXIMUM_ARRAY_SIZE
- See Also:
- Constant Field Values
-
size
protected int size
-
items
protected transient byte[] items
-
-
Method Detail
-
newListWith
public static ByteArrayList newListWith(byte... elements)
Creates a new list using the passedelementsargument as the backing store.!!! WARNING: This method uses the passed in array, so can be very unsafe if the original array is held onto anywhere else. !!!
-
newList
public static ByteArrayList newList(ByteIterable source)
-
newWithNValues
public static ByteArrayList newWithNValues(int size, byte value)
-
wrapCopy
public static ByteArrayList wrapCopy(byte... array)
Creates a new list by first copying the array passed in.
-
size
public int size()
Description copied from interface:PrimitiveIterableReturns the number of items in this iterable.- Specified by:
sizein interfacePrimitiveIterable
-
clear
public void clear()
- Specified by:
clearin interfaceMutableByteCollection
-
contains
public boolean contains(byte value)
Description copied from interface:ByteIterableReturns true if the value is contained in the ByteIterable, and false if it is not.- Specified by:
containsin interfaceByteIterable
-
newIndexOutOfBoundsException
private java.lang.IndexOutOfBoundsException newIndexOutOfBoundsException(int index)
-
getFirst
public byte getFirst()
- Specified by:
getFirstin interfaceOrderedByteIterable
-
getLast
public byte getLast()
- Specified by:
getLastin interfaceReversibleByteIterable
-
checkEmpty
private void checkEmpty()
-
indexOf
public int indexOf(byte value)
- Specified by:
indexOfin interfaceOrderedByteIterable
-
lastIndexOf
public int lastIndexOf(byte value)
- Specified by:
lastIndexOfin interfaceByteList
-
trimToSize
public void trimToSize()
-
transferItemsToNewArrayWithCapacity
private void transferItemsToNewArrayWithCapacity(int newCapacity)
-
copyItemsWithNewCapacity
private byte[] copyItemsWithNewCapacity(int newCapacity)
-
sizePlusFiftyPercent
private int sizePlusFiftyPercent(int oldSize)
-
ensureCapacity
public void ensureCapacity(int minCapacity)
-
ensureCapacityForAdd
private void ensureCapacityForAdd()
-
add
public boolean add(byte newItem)
- Specified by:
addin interfaceMutableByteCollection
-
addAll
public boolean addAll(byte... source)
- Specified by:
addAllin interfaceMutableByteCollection
-
addAll
public boolean addAll(ByteIterable source)
- Specified by:
addAllin interfaceMutableByteCollection
-
copyItems
private void copyItems(int sourceSize, byte[] source)
-
throwOutOfBounds
private void throwOutOfBounds(int index)
-
addAtIndex
public void addAtIndex(int index, byte element)- Specified by:
addAtIndexin interfaceMutableByteList
-
addAtIndexLessThanSize
private void addAtIndexLessThanSize(int index, byte element)
-
addAllAtIndex
public boolean addAllAtIndex(int index, byte... source)- Specified by:
addAllAtIndexin interfaceMutableByteList
-
addAllAtIndex
public boolean addAllAtIndex(int index, ByteIterable source)- Specified by:
addAllAtIndexin interfaceMutableByteList
-
shiftElementsAtIndex
private void shiftElementsAtIndex(int index, int sourceSize)
-
remove
public boolean remove(byte value)
- Specified by:
removein interfaceMutableByteCollection
-
removeIf
public boolean removeIf(BytePredicate predicate)
- Specified by:
removeIfin interfaceMutableByteCollection
-
wipeAndResetTheEnd
private void wipeAndResetTheEnd(int newCurrentFilledIndex)
-
removeAll
public boolean removeAll(ByteIterable source)
- Specified by:
removeAllin interfaceMutableByteCollection
-
removeAll
public boolean removeAll(byte... source)
- Specified by:
removeAllin interfaceMutableByteCollection
-
retainAll
public boolean retainAll(ByteIterable source)
- Specified by:
retainAllin interfaceMutableByteCollection- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(byte... source)
- Specified by:
retainAllin interfaceMutableByteCollection- See Also:
Collection.retainAll(Collection)
-
removeAtIndex
public byte removeAtIndex(int index)
- Specified by:
removeAtIndexin interfaceMutableByteList
-
set
public byte set(int index, byte element)- Specified by:
setin interfaceMutableByteList
-
swap
public void swap(int index1, int index2)- Specified by:
swapin interfaceMutableByteList
-
with
public ByteArrayList with(byte element)
- Specified by:
within interfaceMutableByteCollection- Specified by:
within interfaceMutableByteList
-
without
public ByteArrayList without(byte element)
- Specified by:
withoutin interfaceMutableByteCollection- Specified by:
withoutin interfaceMutableByteList
-
withAll
public ByteArrayList withAll(ByteIterable elements)
- Specified by:
withAllin interfaceMutableByteCollection- Specified by:
withAllin interfaceMutableByteList
-
withoutAll
public ByteArrayList withoutAll(ByteIterable elements)
- Specified by:
withoutAllin interfaceMutableByteCollection- Specified by:
withoutAllin interfaceMutableByteList
-
with
public ByteArrayList with(byte element1, byte element2)
-
with
public ByteArrayList with(byte element1, byte element2, byte element3)
-
with
public ByteArrayList with(byte element1, byte element2, byte element3, byte... elements)
-
withArrayCopy
private ByteArrayList withArrayCopy(byte[] elements, int begin, int length)
-
byteIterator
public MutableByteIterator byteIterator()
Description copied from interface:ByteIterableReturns a primitive iterator that can be used to iterate over the ByteIterable in an imperative style.- Specified by:
byteIteratorin interfaceByteIterable- Specified by:
byteIteratorin interfaceMutableByteCollection
-
each
public void each(ByteProcedure procedure)
Description copied from interface:ByteIterableA synonym for forEach.- Specified by:
eachin interfaceByteIterable- Since:
- 7.0.
-
forEachWithIndex
public void forEachWithIndex(ByteIntProcedure procedure)
- Specified by:
forEachWithIndexin interfaceOrderedByteIterable
-
injectInto
public <T> T injectInto(T injectedValue, ObjectByteToObjectFunction<? super T,? extends T> function)- Specified by:
injectIntoin interfaceByteIterable
-
injectIntoWithIndex
public <T> T injectIntoWithIndex(T injectedValue, ObjectByteIntToObjectFunction<? super T,? extends T> function)- Specified by:
injectIntoWithIndexin interfaceOrderedByteIterable- Specified by:
injectIntoWithIndexin interfaceReversibleByteIterable
-
chunk
public RichIterable<ByteIterable> chunk(int size)
Description copied from interface:ByteIterablePartitions elements in fixed size chunks.- Specified by:
chunkin interfaceByteIterable- Parameters:
size- the number of elements per chunk- Returns:
- A
RichIterablecontainingByteIterables of sizesize, except the last will be truncated if the elements don't divide evenly.
-
count
public int count(BytePredicate predicate)
Description copied from interface:ByteIterableReturns a count of the number of elements in the ByteIterable that return true for the specified predicate.- Specified by:
countin interfaceByteIterable
-
anySatisfy
public boolean anySatisfy(BytePredicate predicate)
Description copied from interface:ByteIterableReturns true if any of the elements in the ByteIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfyin interfaceByteIterable
-
allSatisfy
public boolean allSatisfy(BytePredicate predicate)
Description copied from interface:ByteIterableReturns true if all of the elements in the ByteIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfyin interfaceByteIterable
-
select
public ByteArrayList select(BytePredicate predicate)
Description copied from interface:ByteIterableReturns a new ByteIterable with all of the elements in the ByteIterable that return true for the specified predicate.- Specified by:
selectin interfaceByteIterable- Specified by:
selectin interfaceByteList- Specified by:
selectin interfaceMutableByteCollection- Specified by:
selectin interfaceMutableByteList- Specified by:
selectin interfaceOrderedByteIterable- Specified by:
selectin interfaceReversibleByteIterable
-
select
public <R extends MutableByteCollection> R select(BytePredicate predicate, R target)
Description copied from interface:ByteIterableSame asByteIterable.select(BytePredicate), only the results are added to the target MutableByteCollection.- Specified by:
selectin interfaceByteIterable- Since:
- 8.1.
-
reject
public ByteArrayList reject(BytePredicate predicate)
Description copied from interface:ByteIterableReturns a new ByteIterable with all of the elements in the ByteIterable that return false for the specified predicate.- Specified by:
rejectin interfaceByteIterable- Specified by:
rejectin interfaceByteList- Specified by:
rejectin interfaceMutableByteCollection- Specified by:
rejectin interfaceMutableByteList- Specified by:
rejectin interfaceOrderedByteIterable- Specified by:
rejectin interfaceReversibleByteIterable
-
reject
public <R extends MutableByteCollection> R reject(BytePredicate predicate, R target)
Description copied from interface:ByteIterableSame asByteIterable.reject(BytePredicate), only the results are added to the target MutableByteCollection.- Specified by:
rejectin interfaceByteIterable- Since:
- 8.1.
-
detectIfNone
public byte detectIfNone(BytePredicate predicate, byte ifNone)
- Specified by:
detectIfNonein interfaceByteIterable
-
collect
public <V> MutableList<V> collect(ByteToObjectFunction<? extends V> function)
Description copied from interface:ByteIterableReturns a new collection with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.- Specified by:
collectin interfaceByteIterable- Specified by:
collectin interfaceByteList- Specified by:
collectin interfaceMutableByteCollection- Specified by:
collectin interfaceMutableByteList- Specified by:
collectin interfaceOrderedByteIterable- Specified by:
collectin interfaceReversibleByteIterable
-
collect
public <V,R extends java.util.Collection<V>> R collect(ByteToObjectFunction<? extends V> function, R target)
Description copied from interface:ByteIterableSame asByteIterable.collect(ByteToObjectFunction), only the results are added to the target Collection.- Specified by:
collectin interfaceByteIterable- Since:
- 8.1.
-
max
public byte max()
- Specified by:
maxin interfaceByteIterable
-
min
public byte min()
- Specified by:
minin interfaceByteIterable
-
sum
public long sum()
- Specified by:
sumin interfaceByteIterable
-
dotProduct
public long dotProduct(ByteList list)
- Specified by:
dotProductin interfaceByteList
-
toArray
public byte[] toArray()
Description copied from interface:ByteIterableConverts the ByteIterable to a primitive byte array.- Specified by:
toArrayin interfaceByteIterable
-
toArray
public byte[] toArray(byte[] target)
Description copied from interface:ByteIterableConverts the ByteIterable to a primitive byte array. If the collection fits into the provided array it is used to store its elements and is returned from the method, otherwise a new array of the appropriate size is allocated and returned. If the iterable is empty, the target array is returned unchanged.- Specified by:
toArrayin interfaceByteIterable
-
equals
public boolean equals(java.lang.Object otherList)
Description copied from interface:ByteListFollows the same general contract asList.equals(Object).
-
hashCode
public int hashCode()
Description copied from interface:ByteListFollows the same general contract asList.hashCode().
-
appendString
public void appendString(java.lang.Appendable appendable, java.lang.String start, java.lang.String separator, java.lang.String end)Description copied from interface:PrimitiveIterablePrints a string representation of this collection onto the givenAppendable. Prints the string returned byPrimitiveIterable.makeString(String, String, String).- Specified by:
appendStringin interfacePrimitiveIterable
-
asUnmodifiable
public MutableByteList asUnmodifiable()
- Specified by:
asUnmodifiablein interfaceMutableByteCollection- Specified by:
asUnmodifiablein interfaceMutableByteList
-
asSynchronized
public MutableByteList asSynchronized()
- Specified by:
asSynchronizedin interfaceMutableByteCollection- Specified by:
asSynchronizedin interfaceMutableByteList
-
toImmutable
public ImmutableByteList toImmutable()
Description copied from interface:MutableByteListReturns an immutable copy of this list.- Specified by:
toImmutablein interfaceByteList- Specified by:
toImmutablein interfaceMutableByteCollection- Specified by:
toImmutablein interfaceMutableByteList
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException- Specified by:
readExternalin interfacejava.io.Externalizable- Throws:
java.io.IOException
-
asReversed
public LazyByteIterable asReversed()
- Specified by:
asReversedin interfaceReversibleByteIterable
-
reverseThis
public ByteArrayList reverseThis()
- Specified by:
reverseThisin interfaceMutableByteList
-
sortThis
public ByteArrayList sortThis()
Description copied from interface:MutableByteListSorts this list mutating its contents and returns the same mutable list (this).- Specified by:
sortThisin interfaceMutableByteList
-
sortThis
public ByteArrayList sortThis(ByteComparator comparator)
Description copied from interface:MutableByteListSorts the internal data structure of this list and returns the list itself as a convenience.- Specified by:
sortThisin interfaceMutableByteList
-
toReversed
public ByteArrayList toReversed()
- Specified by:
toReversedin interfaceByteList- Specified by:
toReversedin interfaceMutableByteList- Specified by:
toReversedin interfaceReversibleByteIterable
-
binarySearch
public int binarySearch(byte value)
- Specified by:
binarySearchin interfaceByteList
-
distinct
public MutableByteList distinct()
- Specified by:
distinctin interfaceByteList- Specified by:
distinctin interfaceMutableByteList- Specified by:
distinctin interfaceReversibleByteIterable
-
subList
public MutableByteList subList(int fromIndex, int toIndex)
- Specified by:
subListin interfaceByteList- Specified by:
subListin interfaceMutableByteList- See Also:
List.subList(int fromIndex, int toIndex)
-
zipByte
public MutableList<ByteBytePair> zipByte(ByteIterable iterable)
Description copied from interface:MutableByteListReturns aMutableListformed from thisMutableByteListand anotherByteListby combining corresponding elements in pairs. If one of the twoByteLists is longer than the other, its remaining elements are ignored.- Specified by:
zipBytein interfaceByteList- Specified by:
zipBytein interfaceMutableByteList- Since:
- 9.1.
-
newEmpty
public ByteArrayList newEmpty()
Creates a new empty ByteArrayList.- Specified by:
newEmptyin interfaceMutableByteCollection- Specified by:
newEmptyin interfaceMutableByteList- Since:
- 9.2.
-
zip
public <T> MutableList<ByteObjectPair<T>> zip(java.lang.Iterable<T> iterable)
Description copied from interface:MutableByteListReturns aMutableListformed from thisMutableByteListand aListIterableby combining corresponding elements in pairs. If one of the two Lists is longer than the other, its remaining elements are ignored.- Specified by:
zipin interfaceByteList- Specified by:
zipin interfaceMutableByteList- Since:
- 9.1.
-
boxed
public MutableList<java.lang.Byte> boxed()
- Specified by:
boxedin interfaceMutableByteList
-
toStack
public MutableByteStack toStack()
Description copied from interface:OrderedByteIterableConverts the collection to a ByteStack.- Specified by:
toStackin interfaceOrderedByteIterable
-
-