Class ByteArrayList
java.lang.Object
org.eclipse.collections.impl.primitive.AbstractByteIterable
org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList
- All Implemented Interfaces:
Externalizable, Serializable, ByteIterable, MutableByteCollection, ByteList, MutableByteList, OrderedByteIterable, ReversibleByteIterable, PrimitiveIterable
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:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byte[]protected byte[]private static final intprivate static final longprotected intprivate static final byte[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(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(Appendable appendable, String start, String separator, String end) Prints a string representation of this collection onto the givenAppendable.intbinarySearch(byte value) boxed()Returns a primitive iterator that can be used to iterate over the ByteIterable in an imperative style.private voidchunk(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 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) distinct()longdotProduct(ByteList list) voideach(ByteProcedure procedure) A synonym for forEach.voidensureCapacity(int minCapacity) private voidbooleanFollows 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()newEmpty()Creates a new empty ByteArrayList.private 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) voidreject(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) select(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) sortThis()Sorts this list mutating its contents and returns the same mutable list (this).sortThis(ByteComparator comparator) Sorts the internal data structure of this list and returns the list itself as a convenience.subList(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.Returns an immutable copy of this list.toStack()Converts the collection to a ByteStack.private voidtransferItemsToNewArrayWithCapacity(int newCapacity) voidprivate voidwipeAndResetTheEnd(int newCurrentFilledIndex) with(byte element) with(byte element1, byte element2) with(byte element1, byte element2, byte element3) with(byte element1, byte element2, byte element3, byte... elements) withAll(ByteIterable elements) private ByteArrayListwithArrayCopy(byte[] elements, int begin, int length) without(byte element) withoutAll(ByteIterable elements) static ByteArrayListwrapCopy(byte... array) Creates a new list by first copying the array passed in.void<T> MutableList<ByteObjectPair<T>> Returns aMutableListformed from thisMutableByteListand aListIterableby combining corresponding elements in pairs.zipByte(ByteIterable iterable) Returns aMutableListformed from thisMutableByteListand anotherByteListby combining corresponding elements in pairs.Methods inherited from class AbstractByteIterable
asLazy, average, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toStringMethods inherited from interface 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, toSortedListByMethods inherited from interface ByteList
forEachInBothMethods inherited from interface MutableByteList
collectWithIndex, rejectWithIndex, selectWithIndex, shuffleThis, shuffleThis, sortThisBy, sortThisBy, tapMethods inherited from interface OrderedByteIterable
collectWithIndex, rejectWithIndex, selectWithIndexMethods inherited from interface PrimitiveIterable
appendString, appendString, isEmpty, makeString, makeString, makeString, notEmpty, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
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:
-
size
protected int size -
items
protected transient byte[] items
-
-
Constructor Details
-
ByteArrayList
public ByteArrayList() -
ByteArrayList
public ByteArrayList(int initialCapacity) -
ByteArrayList
public ByteArrayList(byte... array)
-
-
Method Details
-
newListWith
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
-
newWithNValues
-
wrapCopy
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
-
get
-
newIndexOutOfBoundsException
-
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
- 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
- Specified by:
addAllAtIndexin interfaceMutableByteList
-
shiftElementsAtIndex
private void shiftElementsAtIndex(int index, int sourceSize) -
remove
public boolean remove(byte value) - Specified by:
removein interfaceMutableByteCollection
-
removeIf
- Specified by:
removeIfin interfaceMutableByteCollection
-
wipeAndResetTheEnd
private void wipeAndResetTheEnd(int newCurrentFilledIndex) -
removeAll
- Specified by:
removeAllin interfaceMutableByteCollection
-
removeAll
public boolean removeAll(byte... source) - Specified by:
removeAllin interfaceMutableByteCollection
-
retainAll
- Specified by:
retainAllin interfaceMutableByteCollection- See Also:
-
retainAll
public boolean retainAll(byte... source) - Specified by:
retainAllin interfaceMutableByteCollection- See Also:
-
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
- Specified by:
within interfaceMutableByteCollection- Specified by:
within interfaceMutableByteList
-
without
- Specified by:
withoutin interfaceMutableByteCollection- Specified by:
withoutin interfaceMutableByteList
-
withAll
- Specified by:
withAllin interfaceMutableByteCollection- Specified by:
withAllin interfaceMutableByteList
-
withoutAll
- Specified by:
withoutAllin interfaceMutableByteCollection- Specified by:
withoutAllin interfaceMutableByteList
-
with
-
with
-
with
-
withArrayCopy
-
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
Description copied from interface:ByteIterableA synonym for forEach.- Specified by:
eachin interfaceByteIterable- Since:
- 7.0.
-
forEachWithIndex
- 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
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
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
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
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
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
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
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
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
- Specified by:
detectIfNonein interfaceByteIterable
-
collect
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
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
- 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
-
hashCode
-
appendString
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
- Specified by:
asUnmodifiablein interfaceMutableByteCollection- Specified by:
asUnmodifiablein interfaceMutableByteList
-
asSynchronized
- Specified by:
asSynchronizedin interfaceMutableByteCollection- Specified by:
asSynchronizedin interfaceMutableByteList
-
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
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOException
-
asReversed
- Specified by:
asReversedin interfaceReversibleByteIterable
-
reverseThis
- Specified by:
reverseThisin interfaceMutableByteList
-
sortThis
Description copied from interface:MutableByteListSorts this list mutating its contents and returns the same mutable list (this).- Specified by:
sortThisin interfaceMutableByteList
-
sortThis
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
- Specified by:
toReversedin interfaceByteList- Specified by:
toReversedin interfaceMutableByteList- Specified by:
toReversedin interfaceReversibleByteIterable
-
binarySearch
public int binarySearch(byte value) - Specified by:
binarySearchin interfaceByteList
-
distinct
- Specified by:
distinctin interfaceByteList- Specified by:
distinctin interfaceMutableByteList- Specified by:
distinctin interfaceReversibleByteIterable
-
subList
- Specified by:
subListin interfaceByteList- Specified by:
subListin interfaceMutableByteList- See Also:
-
zipByte
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
Creates a new empty ByteArrayList.- Specified by:
newEmptyin interfaceMutableByteCollection- Specified by:
newEmptyin interfaceMutableByteList- Since:
- 9.2.
-
zip
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
- Specified by:
boxedin interfaceMutableByteList
-
toStack
Description copied from interface:OrderedByteIterableConverts the collection to a ByteStack.- Specified by:
toStackin interfaceOrderedByteIterable
-