Class LongArrayList
java.lang.Object
org.eclipse.collections.impl.primitive.AbstractLongIterable
org.eclipse.collections.impl.list.mutable.primitive.LongArrayList
- All Implemented Interfaces:
Externalizable, Serializable, MutableLongCollection, LongList, MutableLongList, LongIterable, OrderedLongIterable, ReversibleLongIterable, PrimitiveIterable
LongArrayList is similar to FastList, and is memory-optimized for long 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 long[]protected long[]private static final intprivate static final longprotected intprivate static final long[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(long newItem) booleanaddAll(long... source) booleanaddAll(LongIterable source) booleanaddAllAtIndex(int index, long... source) booleanaddAllAtIndex(int index, LongIterable source) voidaddAtIndex(int index, long element) private voidaddAtIndexLessThanSize(int index, long element) booleanallSatisfy(LongPredicate predicate) Returns true if all of the elements in the LongIterable return true for the specified predicate, otherwise returns false.booleananySatisfy(LongPredicate predicate) Returns true if any of the elements in the LongIterable 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(long value) boxed()private voidchunk(int size) Partitions elements in fixed size chunks.voidclear()<V> MutableList<V> collect(LongToObjectFunction<? 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(LongToObjectFunction<? extends V> function, R target) Same asLongIterable.collect(LongToObjectFunction), only the results are added to the target Collection.booleancontains(long value) Returns true if the value is contained in the LongIterable, and false if it is not.private voidcopyItems(int sourceSize, long[] source) private long[]copyItemsWithNewCapacity(int newCapacity) intcount(LongPredicate predicate) Returns a count of the number of elements in the LongIterable that return true for the specified predicate.longdetectIfNone(LongPredicate predicate, long ifNone) distinct()longdotProduct(LongList list) voideach(LongProcedure procedure) A synonym for forEach.voidensureCapacity(int minCapacity) private voidbooleanFollows the same general contract asList.equals(Object).voidforEachWithIndex(LongIntProcedure procedure) longget(int index) longgetFirst()longgetLast()inthashCode()Follows the same general contract asList.hashCode().intindexOf(long value) <T> TinjectInto(T injectedValue, ObjectLongToObjectFunction<? super T, ? extends T> function) <T> TinjectIntoWithIndex(T injectedValue, ObjectLongIntToObjectFunction<? super T, ? extends T> function) intlastIndexOf(long value) Returns a primitive iterator that can be used to iterate over the LongIterable in an imperative style.longmax()longmin()newEmpty()Creates a new empty LongArrayList.private IndexOutOfBoundsExceptionnewIndexOutOfBoundsException(int index) static LongArrayListnewList(LongIterable source) static LongArrayListnewListWith(long... elements) Creates a new list using the passedelementsargument as the backing store.static LongArrayListnewWithNValues(int size, long value) voidreject(LongPredicate predicate) Returns a new LongIterable with all of the elements in the LongIterable that return false for the specified predicate.<R extends MutableLongCollection>
Rreject(LongPredicate predicate, R target) Same asLongIterable.reject(LongPredicate), only the results are added to the target MutableLongCollection.booleanremove(long value) booleanremoveAll(long... source) booleanremoveAll(LongIterable source) longremoveAtIndex(int index) booleanremoveIf(LongPredicate predicate) booleanretainAll(long... source) booleanretainAll(LongIterable source) select(LongPredicate predicate) Returns a new LongIterable with all of the elements in the LongIterable that return true for the specified predicate.<R extends MutableLongCollection>
Rselect(LongPredicate predicate, R target) Same asLongIterable.select(LongPredicate), only the results are added to the target MutableLongCollection.longset(int index, long 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(LongComparator 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) long[]toArray()Converts the LongIterable to a primitive long array.long[]toArray(long[] target) Converts the LongIterable to a primitive long array.Returns an immutable copy of this list.toStack()Converts the collection to a LongStack.private voidtransferItemsToNewArrayWithCapacity(int newCapacity) voidprivate voidwipeAndResetTheEnd(int newCurrentFilledIndex) with(long element) with(long element1, long element2) with(long element1, long element2, long element3) with(long element1, long element2, long element3, long... elements) withAll(LongIterable elements) private LongArrayListwithArrayCopy(long[] elements, int begin, int length) without(long element) withoutAll(LongIterable elements) static LongArrayListwrapCopy(long... array) Creates a new list by first copying the array passed in.void<T> MutableList<LongObjectPair<T>> Returns aMutableListformed from thisMutableLongListand aListIterableby combining corresponding elements in pairs.zipLong(LongIterable iterable) Returns aMutableListformed from thisMutableLongListand anotherLongListby combining corresponding elements in pairs.Methods inherited from class AbstractLongIterable
asLazy, average, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toStringMethods inherited from interface LongIterable
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 LongList
forEachInBoth, primitiveParallelStream, primitiveStreamMethods inherited from interface MutableLongList
collectWithIndex, rejectWithIndex, selectWithIndex, shuffleThis, shuffleThis, sortThisBy, sortThisBy, tapMethods inherited from interface OrderedLongIterable
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 long[] DEFAULT_SIZED_EMPTY_ARRAY -
ZERO_SIZED_ARRAY
private static final long[] ZERO_SIZED_ARRAY -
MAXIMUM_ARRAY_SIZE
private static final int MAXIMUM_ARRAY_SIZE- See Also:
-
size
protected int size -
items
protected transient long[] items
-
-
Constructor Details
-
LongArrayList
public LongArrayList() -
LongArrayList
public LongArrayList(int initialCapacity) -
LongArrayList
public LongArrayList(long... 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 interfaceMutableLongCollection
-
contains
public boolean contains(long value) Description copied from interface:LongIterableReturns true if the value is contained in the LongIterable, and false if it is not.- Specified by:
containsin interfaceLongIterable
-
get
-
newIndexOutOfBoundsException
-
getFirst
public long getFirst()- Specified by:
getFirstin interfaceOrderedLongIterable
-
getLast
public long getLast()- Specified by:
getLastin interfaceReversibleLongIterable
-
checkEmpty
private void checkEmpty() -
indexOf
public int indexOf(long value) - Specified by:
indexOfin interfaceOrderedLongIterable
-
lastIndexOf
public int lastIndexOf(long value) - Specified by:
lastIndexOfin interfaceLongList
-
trimToSize
public void trimToSize() -
transferItemsToNewArrayWithCapacity
private void transferItemsToNewArrayWithCapacity(int newCapacity) -
copyItemsWithNewCapacity
private long[] copyItemsWithNewCapacity(int newCapacity) -
sizePlusFiftyPercent
private int sizePlusFiftyPercent(int oldSize) -
ensureCapacity
public void ensureCapacity(int minCapacity) -
ensureCapacityForAdd
private void ensureCapacityForAdd() -
add
public boolean add(long newItem) - Specified by:
addin interfaceMutableLongCollection
-
addAll
public boolean addAll(long... source) - Specified by:
addAllin interfaceMutableLongCollection
-
addAll
- Specified by:
addAllin interfaceMutableLongCollection
-
copyItems
private void copyItems(int sourceSize, long[] source) -
throwOutOfBounds
private void throwOutOfBounds(int index) -
addAtIndex
public void addAtIndex(int index, long element) - Specified by:
addAtIndexin interfaceMutableLongList
-
addAtIndexLessThanSize
private void addAtIndexLessThanSize(int index, long element) -
addAllAtIndex
public boolean addAllAtIndex(int index, long... source) - Specified by:
addAllAtIndexin interfaceMutableLongList
-
addAllAtIndex
- Specified by:
addAllAtIndexin interfaceMutableLongList
-
shiftElementsAtIndex
private void shiftElementsAtIndex(int index, int sourceSize) -
remove
public boolean remove(long value) - Specified by:
removein interfaceMutableLongCollection
-
removeIf
- Specified by:
removeIfin interfaceMutableLongCollection
-
wipeAndResetTheEnd
private void wipeAndResetTheEnd(int newCurrentFilledIndex) -
removeAll
- Specified by:
removeAllin interfaceMutableLongCollection
-
removeAll
public boolean removeAll(long... source) - Specified by:
removeAllin interfaceMutableLongCollection
-
retainAll
- Specified by:
retainAllin interfaceMutableLongCollection- See Also:
-
retainAll
public boolean retainAll(long... source) - Specified by:
retainAllin interfaceMutableLongCollection- See Also:
-
removeAtIndex
public long removeAtIndex(int index) - Specified by:
removeAtIndexin interfaceMutableLongList
-
set
public long set(int index, long element) - Specified by:
setin interfaceMutableLongList
-
swap
public void swap(int index1, int index2) - Specified by:
swapin interfaceMutableLongList
-
with
- Specified by:
within interfaceMutableLongCollection- Specified by:
within interfaceMutableLongList
-
without
- Specified by:
withoutin interfaceMutableLongCollection- Specified by:
withoutin interfaceMutableLongList
-
withAll
- Specified by:
withAllin interfaceMutableLongCollection- Specified by:
withAllin interfaceMutableLongList
-
withoutAll
- Specified by:
withoutAllin interfaceMutableLongCollection- Specified by:
withoutAllin interfaceMutableLongList
-
with
-
with
-
with
-
withArrayCopy
-
longIterator
Description copied from interface:LongIterableReturns a primitive iterator that can be used to iterate over the LongIterable in an imperative style.- Specified by:
longIteratorin interfaceLongIterable- Specified by:
longIteratorin interfaceMutableLongCollection
-
each
Description copied from interface:LongIterableA synonym for forEach.- Specified by:
eachin interfaceLongIterable- Since:
- 7.0.
-
forEachWithIndex
- Specified by:
forEachWithIndexin interfaceOrderedLongIterable
-
injectInto
public <T> T injectInto(T injectedValue, ObjectLongToObjectFunction<? super T, ? extends T> function) - Specified by:
injectIntoin interfaceLongIterable
-
injectIntoWithIndex
public <T> T injectIntoWithIndex(T injectedValue, ObjectLongIntToObjectFunction<? super T, ? extends T> function) - Specified by:
injectIntoWithIndexin interfaceOrderedLongIterable- Specified by:
injectIntoWithIndexin interfaceReversibleLongIterable
-
chunk
Description copied from interface:LongIterablePartitions elements in fixed size chunks.- Specified by:
chunkin interfaceLongIterable- Parameters:
size- the number of elements per chunk- Returns:
- A
RichIterablecontainingLongIterables of sizesize, except the last will be truncated if the elements don't divide evenly.
-
count
Description copied from interface:LongIterableReturns a count of the number of elements in the LongIterable that return true for the specified predicate.- Specified by:
countin interfaceLongIterable
-
anySatisfy
Description copied from interface:LongIterableReturns true if any of the elements in the LongIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfyin interfaceLongIterable
-
allSatisfy
Description copied from interface:LongIterableReturns true if all of the elements in the LongIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfyin interfaceLongIterable
-
select
Description copied from interface:LongIterableReturns a new LongIterable with all of the elements in the LongIterable that return true for the specified predicate.- Specified by:
selectin interfaceLongIterable- Specified by:
selectin interfaceLongList- Specified by:
selectin interfaceMutableLongCollection- Specified by:
selectin interfaceMutableLongList- Specified by:
selectin interfaceOrderedLongIterable- Specified by:
selectin interfaceReversibleLongIterable
-
select
Description copied from interface:LongIterableSame asLongIterable.select(LongPredicate), only the results are added to the target MutableLongCollection.- Specified by:
selectin interfaceLongIterable- Since:
- 8.1.
-
reject
Description copied from interface:LongIterableReturns a new LongIterable with all of the elements in the LongIterable that return false for the specified predicate.- Specified by:
rejectin interfaceLongIterable- Specified by:
rejectin interfaceLongList- Specified by:
rejectin interfaceMutableLongCollection- Specified by:
rejectin interfaceMutableLongList- Specified by:
rejectin interfaceOrderedLongIterable- Specified by:
rejectin interfaceReversibleLongIterable
-
reject
Description copied from interface:LongIterableSame asLongIterable.reject(LongPredicate), only the results are added to the target MutableLongCollection.- Specified by:
rejectin interfaceLongIterable- Since:
- 8.1.
-
detectIfNone
- Specified by:
detectIfNonein interfaceLongIterable
-
collect
Description copied from interface:LongIterableReturns 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 interfaceLongIterable- Specified by:
collectin interfaceLongList- Specified by:
collectin interfaceMutableLongCollection- Specified by:
collectin interfaceMutableLongList- Specified by:
collectin interfaceOrderedLongIterable- Specified by:
collectin interfaceReversibleLongIterable
-
collect
Description copied from interface:LongIterableSame asLongIterable.collect(LongToObjectFunction), only the results are added to the target Collection.- Specified by:
collectin interfaceLongIterable- Since:
- 8.1.
-
max
public long max()- Specified by:
maxin interfaceLongIterable
-
min
public long min()- Specified by:
minin interfaceLongIterable
-
sum
public long sum()- Specified by:
sumin interfaceLongIterable
-
dotProduct
- Specified by:
dotProductin interfaceLongList
-
toArray
public long[] toArray()Description copied from interface:LongIterableConverts the LongIterable to a primitive long array.- Specified by:
toArrayin interfaceLongIterable
-
toArray
public long[] toArray(long[] target) Description copied from interface:LongIterableConverts the LongIterable to a primitive long 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 interfaceLongIterable
-
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 interfaceMutableLongCollection- Specified by:
asUnmodifiablein interfaceMutableLongList
-
asSynchronized
- Specified by:
asSynchronizedin interfaceMutableLongCollection- Specified by:
asSynchronizedin interfaceMutableLongList
-
toImmutable
Description copied from interface:MutableLongListReturns an immutable copy of this list.- Specified by:
toImmutablein interfaceLongList- Specified by:
toImmutablein interfaceMutableLongCollection- Specified by:
toImmutablein interfaceMutableLongList
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOException
-
asReversed
- Specified by:
asReversedin interfaceReversibleLongIterable
-
reverseThis
- Specified by:
reverseThisin interfaceMutableLongList
-
sortThis
Description copied from interface:MutableLongListSorts this list mutating its contents and returns the same mutable list (this).- Specified by:
sortThisin interfaceMutableLongList
-
sortThis
Description copied from interface:MutableLongListSorts the internal data structure of this list and returns the list itself as a convenience.- Specified by:
sortThisin interfaceMutableLongList
-
toReversed
- Specified by:
toReversedin interfaceLongList- Specified by:
toReversedin interfaceMutableLongList- Specified by:
toReversedin interfaceReversibleLongIterable
-
binarySearch
public int binarySearch(long value) - Specified by:
binarySearchin interfaceLongList
-
distinct
- Specified by:
distinctin interfaceLongList- Specified by:
distinctin interfaceMutableLongList- Specified by:
distinctin interfaceReversibleLongIterable
-
subList
- Specified by:
subListin interfaceLongList- Specified by:
subListin interfaceMutableLongList- See Also:
-
zipLong
Description copied from interface:MutableLongListReturns aMutableListformed from thisMutableLongListand anotherLongListby combining corresponding elements in pairs. If one of the twoLongLists is longer than the other, its remaining elements are ignored.- Specified by:
zipLongin interfaceLongList- Specified by:
zipLongin interfaceMutableLongList- Since:
- 9.1.
-
newEmpty
Creates a new empty LongArrayList.- Specified by:
newEmptyin interfaceMutableLongCollection- Specified by:
newEmptyin interfaceMutableLongList- Since:
- 9.2.
-
zip
Description copied from interface:MutableLongListReturns aMutableListformed from thisMutableLongListand 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 interfaceLongList- Specified by:
zipin interfaceMutableLongList- Since:
- 9.1.
-
boxed
- Specified by:
boxedin interfaceMutableLongList
-
toStack
Description copied from interface:OrderedLongIterableConverts the collection to a LongStack.- Specified by:
toStackin interfaceOrderedLongIterable
-
spliterator
- Specified by:
spliteratorin interfaceLongList
-