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
public class ByteArrayList extends AbstractByteIterable implements MutableByteList, 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
-
Constructor Summary
Constructors Constructor Description ByteArrayList()
ByteArrayList(byte... array)
ByteArrayList(int initialCapacity)
-
Method Summary
Modifier and Type Method Description boolean
add(byte newItem)
boolean
addAll(byte... source)
boolean
addAll(ByteIterable source)
boolean
addAllAtIndex(int index, byte... source)
boolean
addAllAtIndex(int index, ByteIterable source)
void
addAtIndex(int index, byte element)
boolean
allSatisfy(BytePredicate predicate)
Returns true if all of the elements in the ByteIterable return true for the specified predicate, otherwise returns false.boolean
anySatisfy(BytePredicate predicate)
Returns true if any of the elements in the ByteIterable return true for the specified predicate, otherwise returns false.void
appendString(Appendable appendable, String start, String separator, String end)
Prints a string representation of this collection onto the givenAppendable
.LazyByteIterable
asReversed()
MutableByteList
asSynchronized()
MutableByteList
asUnmodifiable()
int
binarySearch(byte value)
MutableByteIterator
byteIterator()
Returns a primitive iterator that can be used to iterate over the ByteIterable in an imperative style.RichIterable<ByteIterable>
chunk(int size)
Partitions elements in fixed size chunks.void
clear()
<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.boolean
contains(byte value)
Returns true if the value is contained in the ByteIterable, and false if it is not.int
count(BytePredicate predicate)
Returns a count of the number of elements in the ByteIterable that return true for the specified predicate.byte
detectIfNone(BytePredicate predicate, byte ifNone)
MutableByteList
distinct()
long
dotProduct(ByteList list)
void
each(ByteProcedure procedure)
A synonym for forEach.void
ensureCapacity(int minCapacity)
boolean
equals(Object otherList)
Follows the same general contract asList.equals(Object)
.void
forEach(ByteProcedure procedure)
Applies the ByteProcedure to each element in the ByteIterable.void
forEachWithIndex(ByteIntProcedure procedure)
byte
get(int index)
byte
getFirst()
byte
getLast()
int
hashCode()
Follows the same general contract asList.hashCode()
.int
indexOf(byte value)
<T> T
injectInto(T injectedValue, ObjectByteToObjectFunction<? super T,? extends T> function)
<T> T
injectIntoWithIndex(T injectedValue, ObjectByteIntToObjectFunction<? super T,? extends T> function)
int
lastIndexOf(byte value)
byte
max()
byte
min()
ByteArrayList
newEmpty()
Creates a new empty ByteArrayList.static ByteArrayList
newList(ByteIterable source)
static ByteArrayList
newListWith(byte... elements)
Creates a new list using the passedelements
argument as the backing store.static ByteArrayList
newWithNValues(int size, byte value)
boolean
noneSatisfy(BytePredicate predicate)
Returns true if none of the elements in the ByteIterable return true for the specified predicate, otherwise returns false.void
readExternal(ObjectInput in)
ByteArrayList
reject(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.boolean
remove(byte value)
boolean
removeAll(byte... source)
boolean
removeAll(ByteIterable source)
byte
removeAtIndex(int index)
boolean
removeIf(BytePredicate predicate)
boolean
retainAll(byte... source)
boolean
retainAll(ByteIterable source)
ByteArrayList
reverseThis()
ByteArrayList
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.byte
set(int index, byte element)
int
size()
Returns the number of items in this iterable.ByteArrayList
sortThis()
Sorts this list mutating its contents and returns the same mutable list (this).ByteArrayList
sortThis(ByteComparator comparator)
Sorts the internal data structure of this list and returns the list itself as a convenience.MutableByteList
subList(int fromIndex, int toIndex)
long
sum()
void
swap(int index1, int index2)
byte[]
toArray()
Converts the ByteIterable to a primitive byte array.byte[]
toArray(byte[] target)
Converts the ByteIterable to a primitive byte array.ImmutableByteList
toImmutable()
Returns an immutable copy of this list.ByteArrayList
toReversed()
void
trimToSize()
ByteArrayList
with(byte element)
ByteArrayList
with(byte element1, byte element2)
ByteArrayList
with(byte element1, byte element2, byte element3)
ByteArrayList
with(byte element1, byte element2, byte element3, byte... elements)
ByteArrayList
withAll(ByteIterable elements)
ByteArrayList
without(byte element)
ByteArrayList
withoutAll(ByteIterable elements)
static ByteArrayList
wrapCopy(byte... array)
Creates a new list by first copying the array passed in.void
writeExternal(ObjectOutput out)
<T> MutableList<ByteObjectPair<T>>
zip(Iterable<T> iterable)
Returns aMutableList
formed from thisMutableByteList
and aListIterable
by combining corresponding elements in pairs.MutableList<ByteBytePair>
zipByte(ByteIterable iterable)
Returns aMutableList
formed from thisMutableByteList
and anotherByteList
by combining corresponding elements in pairs.Methods inherited from class org.eclipse.collections.impl.primitive.AbstractByteIterable
asLazy, average, containsAll, containsAll, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toString
Methods inherited from interface org.eclipse.collections.api.ByteIterable
asLazy, average, averageIfEmpty, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectInt, collectLong, collectShort, containsAll, containsAll, flatCollect, maxIfEmpty, median, medianIfEmpty, minIfEmpty, reduce, reduceIfEmpty, summaryStatistics, toBag, toList, toSet, toSortedArray, toSortedList
Methods inherited from interface org.eclipse.collections.api.list.primitive.MutableByteList
collectWithIndex, shuffleThis, shuffleThis, sortThisBy, sortThisBy, tap
Methods inherited from interface org.eclipse.collections.api.ordered.primitive.OrderedByteIterable
collectWithIndex
Methods inherited from interface org.eclipse.collections.api.PrimitiveIterable
appendString, appendString, isEmpty, makeString, makeString, makeString, notEmpty, toString
-
Constructor Details
-
ByteArrayList
public ByteArrayList() -
ByteArrayList
public ByteArrayList(int initialCapacity) -
ByteArrayList
public ByteArrayList(byte... array)
-
-
Method Details
-
newListWith
Creates a new list using the passedelements
argument 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:PrimitiveIterable
Returns the number of items in this iterable.- Specified by:
size
in interfacePrimitiveIterable
-
clear
public void clear()- Specified by:
clear
in interfaceMutableByteCollection
-
contains
public boolean contains(byte value)Description copied from interface:ByteIterable
Returns true if the value is contained in the ByteIterable, and false if it is not.- Specified by:
contains
in interfaceByteIterable
-
get
public byte get(int index) -
getFirst
public byte getFirst()- Specified by:
getFirst
in interfaceOrderedByteIterable
-
getLast
public byte getLast()- Specified by:
getLast
in interfaceReversibleByteIterable
-
indexOf
public int indexOf(byte value)- Specified by:
indexOf
in interfaceOrderedByteIterable
-
lastIndexOf
public int lastIndexOf(byte value)- Specified by:
lastIndexOf
in interfaceByteList
-
trimToSize
public void trimToSize() -
ensureCapacity
public void ensureCapacity(int minCapacity) -
add
public boolean add(byte newItem)- Specified by:
add
in interfaceMutableByteCollection
-
addAll
public boolean addAll(byte... source)- Specified by:
addAll
in interfaceMutableByteCollection
-
addAll
- Specified by:
addAll
in interfaceMutableByteCollection
-
addAtIndex
public void addAtIndex(int index, byte element)- Specified by:
addAtIndex
in interfaceMutableByteList
-
addAllAtIndex
public boolean addAllAtIndex(int index, byte... source)- Specified by:
addAllAtIndex
in interfaceMutableByteList
-
addAllAtIndex
- Specified by:
addAllAtIndex
in interfaceMutableByteList
-
remove
public boolean remove(byte value)- Specified by:
remove
in interfaceMutableByteCollection
-
removeIf
- Specified by:
removeIf
in interfaceMutableByteCollection
-
removeAll
- Specified by:
removeAll
in interfaceMutableByteCollection
-
removeAll
public boolean removeAll(byte... source)- Specified by:
removeAll
in interfaceMutableByteCollection
-
retainAll
- Specified by:
retainAll
in interfaceMutableByteCollection
- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(byte... source)- Specified by:
retainAll
in interfaceMutableByteCollection
- See Also:
Collection.retainAll(Collection)
-
removeAtIndex
public byte removeAtIndex(int index)- Specified by:
removeAtIndex
in interfaceMutableByteList
-
set
public byte set(int index, byte element)- Specified by:
set
in interfaceMutableByteList
-
swap
public void swap(int index1, int index2)- Specified by:
swap
in interfaceMutableByteList
-
with
- Specified by:
with
in interfaceMutableByteCollection
- Specified by:
with
in interfaceMutableByteList
-
without
- Specified by:
without
in interfaceMutableByteCollection
- Specified by:
without
in interfaceMutableByteList
-
withAll
- Specified by:
withAll
in interfaceMutableByteCollection
- Specified by:
withAll
in interfaceMutableByteList
-
withoutAll
- Specified by:
withoutAll
in interfaceMutableByteCollection
- Specified by:
withoutAll
in interfaceMutableByteList
-
with
-
with
-
with
-
byteIterator
Description copied from interface:ByteIterable
Returns a primitive iterator that can be used to iterate over the ByteIterable in an imperative style.- Specified by:
byteIterator
in interfaceByteIterable
- Specified by:
byteIterator
in interfaceMutableByteCollection
-
forEach
Description copied from interface:ByteIterable
Applies the ByteProcedure to each element in the ByteIterable.- Specified by:
forEach
in interfaceByteIterable
-
each
Description copied from interface:ByteIterable
A synonym for forEach.- Specified by:
each
in interfaceByteIterable
- Since:
- 7.0.
-
forEachWithIndex
- Specified by:
forEachWithIndex
in interfaceOrderedByteIterable
-
injectInto
public <T> T injectInto(T injectedValue, ObjectByteToObjectFunction<? super T,? extends T> function)- Specified by:
injectInto
in interfaceByteIterable
-
injectIntoWithIndex
public <T> T injectIntoWithIndex(T injectedValue, ObjectByteIntToObjectFunction<? super T,? extends T> function)- Specified by:
injectIntoWithIndex
in interfaceOrderedByteIterable
- Specified by:
injectIntoWithIndex
in interfaceReversibleByteIterable
-
chunk
Description copied from interface:ByteIterable
Partitions elements in fixed size chunks.- Specified by:
chunk
in interfaceByteIterable
- Parameters:
size
- the number of elements per chunk- Returns:
- A
RichIterable
containingByteIterable
s of sizesize
, except the last will be truncated if the elements don't divide evenly.
-
count
Description copied from interface:ByteIterable
Returns a count of the number of elements in the ByteIterable that return true for the specified predicate.- Specified by:
count
in interfaceByteIterable
-
anySatisfy
Description copied from interface:ByteIterable
Returns true if any of the elements in the ByteIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfy
in interfaceByteIterable
-
allSatisfy
Description copied from interface:ByteIterable
Returns true if all of the elements in the ByteIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfy
in interfaceByteIterable
-
noneSatisfy
Description copied from interface:ByteIterable
Returns true if none of the elements in the ByteIterable return true for the specified predicate, otherwise returns false.- Specified by:
noneSatisfy
in interfaceByteIterable
-
select
Description copied from interface:ByteIterable
Returns a new ByteIterable with all of the elements in the ByteIterable that return true for the specified predicate.- Specified by:
select
in interfaceByteIterable
- Specified by:
select
in interfaceByteList
- Specified by:
select
in interfaceMutableByteCollection
- Specified by:
select
in interfaceMutableByteList
- Specified by:
select
in interfaceOrderedByteIterable
- Specified by:
select
in interfaceReversibleByteIterable
-
select
Description copied from interface:ByteIterable
Same asByteIterable.select(BytePredicate)
, only the results are added to the target MutableByteCollection.- Specified by:
select
in interfaceByteIterable
- Since:
- 8.1.
-
reject
Description copied from interface:ByteIterable
Returns a new ByteIterable with all of the elements in the ByteIterable that return false for the specified predicate.- Specified by:
reject
in interfaceByteIterable
- Specified by:
reject
in interfaceByteList
- Specified by:
reject
in interfaceMutableByteCollection
- Specified by:
reject
in interfaceMutableByteList
- Specified by:
reject
in interfaceOrderedByteIterable
- Specified by:
reject
in interfaceReversibleByteIterable
-
reject
Description copied from interface:ByteIterable
Same asByteIterable.reject(BytePredicate)
, only the results are added to the target MutableByteCollection.- Specified by:
reject
in interfaceByteIterable
- Since:
- 8.1.
-
detectIfNone
- Specified by:
detectIfNone
in interfaceByteIterable
-
collect
Description copied from interface:ByteIterable
Returns 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:
collect
in interfaceByteIterable
- Specified by:
collect
in interfaceByteList
- Specified by:
collect
in interfaceMutableByteCollection
- Specified by:
collect
in interfaceMutableByteList
- Specified by:
collect
in interfaceOrderedByteIterable
- Specified by:
collect
in interfaceReversibleByteIterable
-
collect
public <V, R extends Collection<V>> R collect(ByteToObjectFunction<? extends V> function, R target)Description copied from interface:ByteIterable
Same asByteIterable.collect(ByteToObjectFunction)
, only the results are added to the target Collection.- Specified by:
collect
in interfaceByteIterable
- Since:
- 8.1.
-
max
public byte max()- Specified by:
max
in interfaceByteIterable
-
min
public byte min()- Specified by:
min
in interfaceByteIterable
-
sum
public long sum()- Specified by:
sum
in interfaceByteIterable
-
dotProduct
- Specified by:
dotProduct
in interfaceByteList
-
toArray
public byte[] toArray()Description copied from interface:ByteIterable
Converts the ByteIterable to a primitive byte array.- Specified by:
toArray
in interfaceByteIterable
-
toArray
public byte[] toArray(byte[] target)Description copied from interface:ByteIterable
Converts 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:
toArray
in interfaceByteIterable
-
equals
Description copied from interface:ByteList
Follows the same general contract asList.equals(Object)
. -
hashCode
public int hashCode()Description copied from interface:ByteList
Follows the same general contract asList.hashCode()
. -
appendString
Description copied from interface:PrimitiveIterable
Prints a string representation of this collection onto the givenAppendable
. Prints the string returned byPrimitiveIterable.makeString(String, String, String)
.- Specified by:
appendString
in interfacePrimitiveIterable
-
asUnmodifiable
- Specified by:
asUnmodifiable
in interfaceMutableByteCollection
- Specified by:
asUnmodifiable
in interfaceMutableByteList
-
asSynchronized
- Specified by:
asSynchronized
in interfaceMutableByteCollection
- Specified by:
asSynchronized
in interfaceMutableByteList
-
toImmutable
Description copied from interface:MutableByteList
Returns an immutable copy of this list.- Specified by:
toImmutable
in interfaceByteList
- Specified by:
toImmutable
in interfaceMutableByteCollection
- Specified by:
toImmutable
in interfaceMutableByteList
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
-
asReversed
- Specified by:
asReversed
in interfaceReversibleByteIterable
-
reverseThis
- Specified by:
reverseThis
in interfaceMutableByteList
-
sortThis
Description copied from interface:MutableByteList
Sorts this list mutating its contents and returns the same mutable list (this).- Specified by:
sortThis
in interfaceMutableByteList
-
sortThis
Description copied from interface:MutableByteList
Sorts the internal data structure of this list and returns the list itself as a convenience.- Specified by:
sortThis
in interfaceMutableByteList
-
toReversed
- Specified by:
toReversed
in interfaceByteList
- Specified by:
toReversed
in interfaceMutableByteList
- Specified by:
toReversed
in interfaceReversibleByteIterable
-
binarySearch
public int binarySearch(byte value)- Specified by:
binarySearch
in interfaceByteList
-
distinct
- Specified by:
distinct
in interfaceByteList
- Specified by:
distinct
in interfaceMutableByteList
- Specified by:
distinct
in interfaceReversibleByteIterable
-
subList
- Specified by:
subList
in interfaceByteList
- Specified by:
subList
in interfaceMutableByteList
- See Also:
List.subList(int fromIndex, int toIndex)
-
zipByte
Description copied from interface:MutableByteList
Returns aMutableList
formed from thisMutableByteList
and anotherByteList
by combining corresponding elements in pairs. If one of the twoByteList
s is longer than the other, its remaining elements are ignored.- Specified by:
zipByte
in interfaceByteList
- Specified by:
zipByte
in interfaceMutableByteList
- Since:
- 9.1.
-
newEmpty
Creates a new empty ByteArrayList.- Specified by:
newEmpty
in interfaceMutableByteCollection
- Specified by:
newEmpty
in interfaceMutableByteList
- Since:
- 9.2.
-
zip
Description copied from interface:MutableByteList
Returns aMutableList
formed from thisMutableByteList
and aListIterable
by combining corresponding elements in pairs. If one of the two Lists is longer than the other, its remaining elements are ignored.- Specified by:
zip
in interfaceByteList
- Specified by:
zip
in interfaceMutableByteList
- Since:
- 9.1.
-