Class LongArrayList
- java.lang.Object
-
- org.eclipse.collections.impl.primitive.AbstractLongIterable
-
- org.eclipse.collections.impl.list.mutable.primitive.LongArrayList
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,MutableLongCollection,LongList,MutableLongList,LongIterable,OrderedLongIterable,ReversibleLongIterable,PrimitiveIterable
public class LongArrayList extends AbstractLongIterable implements MutableLongList, java.io.Externalizable
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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classLongArrayList.InternalLongIterator
-
Field Summary
Fields Modifier and Type Field Description private static long[]DEFAULT_SIZED_EMPTY_ARRAYprotected long[]itemsprivate static intMAXIMUM_ARRAY_SIZEprivate static longserialVersionUIDprotected intsizeprivate static long[]ZERO_SIZED_ARRAY
-
Constructor Summary
Constructors Constructor Description LongArrayList()LongArrayList(int initialCapacity)LongArrayList(long... array)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(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(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.LazyLongIterableasReversed()MutableLongListasSynchronized()MutableLongListasUnmodifiable()intbinarySearch(long value)MutableList<java.lang.Long>boxed()private voidcheckEmpty()RichIterable<LongIterable>chunk(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 java.util.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)MutableLongListdistinct()longdotProduct(LongList list)voideach(LongProcedure procedure)A synonym for forEach.voidensureCapacity(int minCapacity)private voidensureCapacityForAdd()booleanequals(java.lang.Object otherList)Follows 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)MutableLongIteratorlongIterator()Returns a primitive iterator that can be used to iterate over the LongIterable in an imperative style.longmax()longmin()LongArrayListnewEmpty()Creates a new empty LongArrayList.private java.lang.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)voidreadExternal(java.io.ObjectInput in)LongArrayListreject(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)LongArrayListreverseThis()LongArrayListselect(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)LongArrayListsortThis()Sorts this list mutating its contents and returns the same mutable list (this).LongArrayListsortThis(LongComparator comparator)Sorts the internal data structure of this list and returns the list itself as a convenience.java.util.Spliterator.OfLongspliterator()MutableLongListsubList(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.ImmutableLongListtoImmutable()Returns an immutable copy of this list.LongArrayListtoReversed()MutableLongStacktoStack()Converts the collection to a LongStack.private voidtransferItemsToNewArrayWithCapacity(int newCapacity)voidtrimToSize()private voidwipeAndResetTheEnd(int newCurrentFilledIndex)LongArrayListwith(long element)LongArrayListwith(long element1, long element2)LongArrayListwith(long element1, long element2, long element3)LongArrayListwith(long element1, long element2, long element3, long... elements)LongArrayListwithAll(LongIterable elements)private LongArrayListwithArrayCopy(long[] elements, int begin, int length)LongArrayListwithout(long element)LongArrayListwithoutAll(LongIterable elements)static LongArrayListwrapCopy(long... array)Creates a new list by first copying the array passed in.voidwriteExternal(java.io.ObjectOutput out)<T> MutableList<LongObjectPair<T>>zip(java.lang.Iterable<T> iterable)Returns aMutableListformed from thisMutableLongListand aListIterableby combining corresponding elements in pairs.MutableList<LongLongPair>zipLong(LongIterable iterable)Returns aMutableListformed from thisMutableLongListand anotherLongListby combining corresponding elements in pairs.-
Methods inherited from class org.eclipse.collections.impl.primitive.AbstractLongIterable
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.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, toSortedListBy
-
Methods inherited from interface org.eclipse.collections.api.list.primitive.LongList
forEachInBoth, primitiveParallelStream, primitiveStream
-
Methods inherited from interface org.eclipse.collections.api.list.primitive.MutableLongList
collectWithIndex, rejectWithIndex, selectWithIndex, shuffleThis, shuffleThis, sortThisBy, sortThisBy, tap
-
Methods inherited from interface org.eclipse.collections.api.ordered.primitive.OrderedLongIterable
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 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:
- Constant Field Values
-
size
protected int size
-
items
protected transient long[] items
-
-
Method Detail
-
newListWith
public static LongArrayList newListWith(long... 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 LongArrayList newList(LongIterable source)
-
newWithNValues
public static LongArrayList newWithNValues(int size, long value)
-
wrapCopy
public static LongArrayList wrapCopy(long... 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 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
-
newIndexOutOfBoundsException
private java.lang.IndexOutOfBoundsException newIndexOutOfBoundsException(int index)
-
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
public boolean addAll(LongIterable source)
- 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
public boolean addAllAtIndex(int index, LongIterable source)- Specified by:
addAllAtIndexin interfaceMutableLongList
-
shiftElementsAtIndex
private void shiftElementsAtIndex(int index, int sourceSize)
-
remove
public boolean remove(long value)
- Specified by:
removein interfaceMutableLongCollection
-
removeIf
public boolean removeIf(LongPredicate predicate)
- Specified by:
removeIfin interfaceMutableLongCollection
-
wipeAndResetTheEnd
private void wipeAndResetTheEnd(int newCurrentFilledIndex)
-
removeAll
public boolean removeAll(LongIterable source)
- Specified by:
removeAllin interfaceMutableLongCollection
-
removeAll
public boolean removeAll(long... source)
- Specified by:
removeAllin interfaceMutableLongCollection
-
retainAll
public boolean retainAll(LongIterable source)
- Specified by:
retainAllin interfaceMutableLongCollection- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(long... source)
- Specified by:
retainAllin interfaceMutableLongCollection- See Also:
Collection.retainAll(Collection)
-
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
public LongArrayList with(long element)
- Specified by:
within interfaceMutableLongCollection- Specified by:
within interfaceMutableLongList
-
without
public LongArrayList without(long element)
- Specified by:
withoutin interfaceMutableLongCollection- Specified by:
withoutin interfaceMutableLongList
-
withAll
public LongArrayList withAll(LongIterable elements)
- Specified by:
withAllin interfaceMutableLongCollection- Specified by:
withAllin interfaceMutableLongList
-
withoutAll
public LongArrayList withoutAll(LongIterable elements)
- Specified by:
withoutAllin interfaceMutableLongCollection- Specified by:
withoutAllin interfaceMutableLongList
-
with
public LongArrayList with(long element1, long element2)
-
with
public LongArrayList with(long element1, long element2, long element3)
-
with
public LongArrayList with(long element1, long element2, long element3, long... elements)
-
withArrayCopy
private LongArrayList withArrayCopy(long[] elements, int begin, int length)
-
longIterator
public MutableLongIterator 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
public void each(LongProcedure procedure)
Description copied from interface:LongIterableA synonym for forEach.- Specified by:
eachin interfaceLongIterable- Since:
- 7.0.
-
forEachWithIndex
public void forEachWithIndex(LongIntProcedure procedure)
- 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
public RichIterable<LongIterable> chunk(int size)
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
public int count(LongPredicate predicate)
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
public boolean anySatisfy(LongPredicate predicate)
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
public boolean allSatisfy(LongPredicate predicate)
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
public LongArrayList select(LongPredicate predicate)
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
public <R extends MutableLongCollection> R select(LongPredicate predicate, R target)
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
public LongArrayList reject(LongPredicate predicate)
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
public <R extends MutableLongCollection> R reject(LongPredicate predicate, R target)
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
public long detectIfNone(LongPredicate predicate, long ifNone)
- Specified by:
detectIfNonein interfaceLongIterable
-
collect
public <V> MutableList<V> collect(LongToObjectFunction<? extends V> function)
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
public <V,R extends java.util.Collection<V>> R collect(LongToObjectFunction<? extends V> function, R target)
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
public long dotProduct(LongList list)
- 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
public boolean equals(java.lang.Object otherList)
Description copied from interface:LongListFollows the same general contract asList.equals(Object).
-
hashCode
public int hashCode()
Description copied from interface:LongListFollows 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 MutableLongList asUnmodifiable()
- Specified by:
asUnmodifiablein interfaceMutableLongCollection- Specified by:
asUnmodifiablein interfaceMutableLongList
-
asSynchronized
public MutableLongList asSynchronized()
- Specified by:
asSynchronizedin interfaceMutableLongCollection- Specified by:
asSynchronizedin interfaceMutableLongList
-
toImmutable
public ImmutableLongList 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
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 LazyLongIterable asReversed()
- Specified by:
asReversedin interfaceReversibleLongIterable
-
reverseThis
public LongArrayList reverseThis()
- Specified by:
reverseThisin interfaceMutableLongList
-
sortThis
public LongArrayList sortThis()
Description copied from interface:MutableLongListSorts this list mutating its contents and returns the same mutable list (this).- Specified by:
sortThisin interfaceMutableLongList
-
sortThis
public LongArrayList sortThis(LongComparator comparator)
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
public LongArrayList toReversed()
- Specified by:
toReversedin interfaceLongList- Specified by:
toReversedin interfaceMutableLongList- Specified by:
toReversedin interfaceReversibleLongIterable
-
binarySearch
public int binarySearch(long value)
- Specified by:
binarySearchin interfaceLongList
-
distinct
public MutableLongList distinct()
- Specified by:
distinctin interfaceLongList- Specified by:
distinctin interfaceMutableLongList- Specified by:
distinctin interfaceReversibleLongIterable
-
subList
public MutableLongList subList(int fromIndex, int toIndex)
- Specified by:
subListin interfaceLongList- Specified by:
subListin interfaceMutableLongList- See Also:
List.subList(int fromIndex, int toIndex)
-
zipLong
public MutableList<LongLongPair> zipLong(LongIterable iterable)
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
public LongArrayList newEmpty()
Creates a new empty LongArrayList.- Specified by:
newEmptyin interfaceMutableLongCollection- Specified by:
newEmptyin interfaceMutableLongList- Since:
- 9.2.
-
zip
public <T> MutableList<LongObjectPair<T>> zip(java.lang.Iterable<T> iterable)
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
public MutableList<java.lang.Long> boxed()
- Specified by:
boxedin interfaceMutableLongList
-
toStack
public MutableLongStack toStack()
Description copied from interface:OrderedLongIterableConverts the collection to a LongStack.- Specified by:
toStackin interfaceOrderedLongIterable
-
spliterator
public java.util.Spliterator.OfLong spliterator()
- Specified by:
spliteratorin interfaceLongList
-
-