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 class
LongArrayList.InternalLongIterator
-
Field Summary
Fields Modifier and Type Field Description private static long[]
DEFAULT_SIZED_EMPTY_ARRAY
protected long[]
items
private static int
MAXIMUM_ARRAY_SIZE
private static long
serialVersionUID
protected int
size
private 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 boolean
add(long newItem)
boolean
addAll(long... source)
boolean
addAll(LongIterable source)
boolean
addAllAtIndex(int index, long... source)
boolean
addAllAtIndex(int index, LongIterable source)
void
addAtIndex(int index, long element)
private void
addAtIndexLessThanSize(int index, long element)
boolean
allSatisfy(LongPredicate predicate)
Returns true if all of the elements in the LongIterable return true for the specified predicate, otherwise returns false.boolean
anySatisfy(LongPredicate predicate)
Returns true if any of the elements in the LongIterable return true for the specified predicate, otherwise returns false.void
appendString(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
.LazyLongIterable
asReversed()
MutableLongList
asSynchronized()
MutableLongList
asUnmodifiable()
int
binarySearch(long value)
private void
checkEmpty()
RichIterable<LongIterable>
chunk(int size)
Partitions elements in fixed size chunks.void
clear()
<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.boolean
contains(long value)
Returns true if the value is contained in the LongIterable, and false if it is not.private void
copyItems(int sourceSize, long[] source)
private long[]
copyItemsWithNewCapacity(int newCapacity)
int
count(LongPredicate predicate)
Returns a count of the number of elements in the LongIterable that return true for the specified predicate.long
detectIfNone(LongPredicate predicate, long ifNone)
MutableLongList
distinct()
long
dotProduct(LongList list)
void
each(LongProcedure procedure)
A synonym for forEach.void
ensureCapacity(int minCapacity)
private void
ensureCapacityForAdd()
boolean
equals(java.lang.Object otherList)
Follows the same general contract asList.equals(Object)
.void
forEachWithIndex(LongIntProcedure procedure)
long
get(int index)
long
getFirst()
long
getLast()
int
hashCode()
Follows the same general contract asList.hashCode()
.int
indexOf(long value)
<T> T
injectInto(T injectedValue, ObjectLongToObjectFunction<? super T,? extends T> function)
<T> T
injectIntoWithIndex(T injectedValue, ObjectLongIntToObjectFunction<? super T,? extends T> function)
int
lastIndexOf(long value)
MutableLongIterator
longIterator()
Returns a primitive iterator that can be used to iterate over the LongIterable in an imperative style.long
max()
long
min()
LongArrayList
newEmpty()
Creates a new empty LongArrayList.private java.lang.IndexOutOfBoundsException
newIndexOutOfBoundsException(int index)
static LongArrayList
newList(LongIterable source)
static LongArrayList
newListWith(long... elements)
Creates a new list using the passedelements
argument as the backing store.static LongArrayList
newWithNValues(int size, long value)
void
readExternal(java.io.ObjectInput in)
LongArrayList
reject(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.boolean
remove(long value)
boolean
removeAll(long... source)
boolean
removeAll(LongIterable source)
long
removeAtIndex(int index)
boolean
removeIf(LongPredicate predicate)
boolean
retainAll(long... source)
boolean
retainAll(LongIterable source)
LongArrayList
reverseThis()
LongArrayList
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.long
set(int index, long element)
private void
shiftElementsAtIndex(int index, int sourceSize)
int
size()
Returns the number of items in this iterable.private int
sizePlusFiftyPercent(int oldSize)
LongArrayList
sortThis()
Sorts this list mutating its contents and returns the same mutable list (this).LongArrayList
sortThis(LongComparator comparator)
Sorts the internal data structure of this list and returns the list itself as a convenience.java.util.Spliterator.OfLong
spliterator()
MutableLongList
subList(int fromIndex, int toIndex)
long
sum()
void
swap(int index1, int index2)
private void
throwOutOfBounds(int index)
long[]
toArray()
Converts the LongIterable to a primitive long array.long[]
toArray(long[] target)
Converts the LongIterable to a primitive long array.ImmutableLongList
toImmutable()
Returns an immutable copy of this list.LongArrayList
toReversed()
private void
transferItemsToNewArrayWithCapacity(int newCapacity)
void
trimToSize()
private void
wipeAndResetTheEnd(int newCurrentFilledIndex)
LongArrayList
with(long element)
LongArrayList
with(long element1, long element2)
LongArrayList
with(long element1, long element2, long element3)
LongArrayList
with(long element1, long element2, long element3, long... elements)
LongArrayList
withAll(LongIterable elements)
private LongArrayList
withArrayCopy(long[] elements, int begin, int length)
LongArrayList
without(long element)
LongArrayList
withoutAll(LongIterable elements)
static LongArrayList
wrapCopy(long... array)
Creates a new list by first copying the array passed in.void
writeExternal(java.io.ObjectOutput out)
<T> MutableList<LongObjectPair<T>>
zip(java.lang.Iterable<T> iterable)
Returns aMutableList
formed from thisMutableLongList
and aListIterable
by combining corresponding elements in pairs.MutableList<LongLongPair>
zipLong(LongIterable iterable)
Returns aMutableList
formed from thisMutableLongList
and anotherLongList
by 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 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
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:PrimitiveIterable
Returns the number of items in this iterable.- Specified by:
size
in interfacePrimitiveIterable
-
clear
public void clear()
- Specified by:
clear
in interfaceMutableLongCollection
-
contains
public boolean contains(long value)
Description copied from interface:LongIterable
Returns true if the value is contained in the LongIterable, and false if it is not.- Specified by:
contains
in interfaceLongIterable
-
newIndexOutOfBoundsException
private java.lang.IndexOutOfBoundsException newIndexOutOfBoundsException(int index)
-
getFirst
public long getFirst()
- Specified by:
getFirst
in interfaceOrderedLongIterable
-
getLast
public long getLast()
- Specified by:
getLast
in interfaceReversibleLongIterable
-
checkEmpty
private void checkEmpty()
-
indexOf
public int indexOf(long value)
- Specified by:
indexOf
in interfaceOrderedLongIterable
-
lastIndexOf
public int lastIndexOf(long value)
- Specified by:
lastIndexOf
in 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:
add
in interfaceMutableLongCollection
-
addAll
public boolean addAll(long... source)
- Specified by:
addAll
in interfaceMutableLongCollection
-
addAll
public boolean addAll(LongIterable source)
- Specified by:
addAll
in 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:
addAtIndex
in interfaceMutableLongList
-
addAtIndexLessThanSize
private void addAtIndexLessThanSize(int index, long element)
-
addAllAtIndex
public boolean addAllAtIndex(int index, long... source)
- Specified by:
addAllAtIndex
in interfaceMutableLongList
-
addAllAtIndex
public boolean addAllAtIndex(int index, LongIterable source)
- Specified by:
addAllAtIndex
in interfaceMutableLongList
-
shiftElementsAtIndex
private void shiftElementsAtIndex(int index, int sourceSize)
-
remove
public boolean remove(long value)
- Specified by:
remove
in interfaceMutableLongCollection
-
removeIf
public boolean removeIf(LongPredicate predicate)
- Specified by:
removeIf
in interfaceMutableLongCollection
-
wipeAndResetTheEnd
private void wipeAndResetTheEnd(int newCurrentFilledIndex)
-
removeAll
public boolean removeAll(LongIterable source)
- Specified by:
removeAll
in interfaceMutableLongCollection
-
removeAll
public boolean removeAll(long... source)
- Specified by:
removeAll
in interfaceMutableLongCollection
-
retainAll
public boolean retainAll(LongIterable source)
- Specified by:
retainAll
in interfaceMutableLongCollection
- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(long... source)
- Specified by:
retainAll
in interfaceMutableLongCollection
- See Also:
Collection.retainAll(Collection)
-
removeAtIndex
public long removeAtIndex(int index)
- Specified by:
removeAtIndex
in interfaceMutableLongList
-
set
public long set(int index, long element)
- Specified by:
set
in interfaceMutableLongList
-
swap
public void swap(int index1, int index2)
- Specified by:
swap
in interfaceMutableLongList
-
with
public LongArrayList with(long element)
- Specified by:
with
in interfaceMutableLongCollection
- Specified by:
with
in interfaceMutableLongList
-
without
public LongArrayList without(long element)
- Specified by:
without
in interfaceMutableLongCollection
- Specified by:
without
in interfaceMutableLongList
-
withAll
public LongArrayList withAll(LongIterable elements)
- Specified by:
withAll
in interfaceMutableLongCollection
- Specified by:
withAll
in interfaceMutableLongList
-
withoutAll
public LongArrayList withoutAll(LongIterable elements)
- Specified by:
withoutAll
in interfaceMutableLongCollection
- Specified by:
withoutAll
in 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:LongIterable
Returns a primitive iterator that can be used to iterate over the LongIterable in an imperative style.- Specified by:
longIterator
in interfaceLongIterable
- Specified by:
longIterator
in interfaceMutableLongCollection
-
each
public void each(LongProcedure procedure)
Description copied from interface:LongIterable
A synonym for forEach.- Specified by:
each
in interfaceLongIterable
- Since:
- 7.0.
-
forEachWithIndex
public void forEachWithIndex(LongIntProcedure procedure)
- Specified by:
forEachWithIndex
in interfaceOrderedLongIterable
-
injectInto
public <T> T injectInto(T injectedValue, ObjectLongToObjectFunction<? super T,? extends T> function)
- Specified by:
injectInto
in interfaceLongIterable
-
injectIntoWithIndex
public <T> T injectIntoWithIndex(T injectedValue, ObjectLongIntToObjectFunction<? super T,? extends T> function)
- Specified by:
injectIntoWithIndex
in interfaceOrderedLongIterable
- Specified by:
injectIntoWithIndex
in interfaceReversibleLongIterable
-
chunk
public RichIterable<LongIterable> chunk(int size)
Description copied from interface:LongIterable
Partitions elements in fixed size chunks.- Specified by:
chunk
in interfaceLongIterable
- Parameters:
size
- the number of elements per chunk- Returns:
- A
RichIterable
containingLongIterable
s 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:LongIterable
Returns a count of the number of elements in the LongIterable that return true for the specified predicate.- Specified by:
count
in interfaceLongIterable
-
anySatisfy
public boolean anySatisfy(LongPredicate predicate)
Description copied from interface:LongIterable
Returns true if any of the elements in the LongIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfy
in interfaceLongIterable
-
allSatisfy
public boolean allSatisfy(LongPredicate predicate)
Description copied from interface:LongIterable
Returns true if all of the elements in the LongIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfy
in interfaceLongIterable
-
select
public LongArrayList select(LongPredicate predicate)
Description copied from interface:LongIterable
Returns a new LongIterable with all of the elements in the LongIterable that return true for the specified predicate.- Specified by:
select
in interfaceLongIterable
- Specified by:
select
in interfaceLongList
- Specified by:
select
in interfaceMutableLongCollection
- Specified by:
select
in interfaceMutableLongList
- Specified by:
select
in interfaceOrderedLongIterable
- Specified by:
select
in interfaceReversibleLongIterable
-
select
public <R extends MutableLongCollection> R select(LongPredicate predicate, R target)
Description copied from interface:LongIterable
Same asLongIterable.select(LongPredicate)
, only the results are added to the target MutableLongCollection.- Specified by:
select
in interfaceLongIterable
- Since:
- 8.1.
-
reject
public LongArrayList reject(LongPredicate predicate)
Description copied from interface:LongIterable
Returns a new LongIterable with all of the elements in the LongIterable that return false for the specified predicate.- Specified by:
reject
in interfaceLongIterable
- Specified by:
reject
in interfaceLongList
- Specified by:
reject
in interfaceMutableLongCollection
- Specified by:
reject
in interfaceMutableLongList
- Specified by:
reject
in interfaceOrderedLongIterable
- Specified by:
reject
in interfaceReversibleLongIterable
-
reject
public <R extends MutableLongCollection> R reject(LongPredicate predicate, R target)
Description copied from interface:LongIterable
Same asLongIterable.reject(LongPredicate)
, only the results are added to the target MutableLongCollection.- Specified by:
reject
in interfaceLongIterable
- Since:
- 8.1.
-
detectIfNone
public long detectIfNone(LongPredicate predicate, long ifNone)
- Specified by:
detectIfNone
in interfaceLongIterable
-
collect
public <V> MutableList<V> collect(LongToObjectFunction<? extends V> function)
Description copied from interface:LongIterable
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 interfaceLongIterable
- Specified by:
collect
in interfaceLongList
- Specified by:
collect
in interfaceMutableLongCollection
- Specified by:
collect
in interfaceMutableLongList
- Specified by:
collect
in interfaceOrderedLongIterable
- Specified by:
collect
in interfaceReversibleLongIterable
-
collect
public <V,R extends java.util.Collection<V>> R collect(LongToObjectFunction<? extends V> function, R target)
Description copied from interface:LongIterable
Same asLongIterable.collect(LongToObjectFunction)
, only the results are added to the target Collection.- Specified by:
collect
in interfaceLongIterable
- Since:
- 8.1.
-
max
public long max()
- Specified by:
max
in interfaceLongIterable
-
min
public long min()
- Specified by:
min
in interfaceLongIterable
-
sum
public long sum()
- Specified by:
sum
in interfaceLongIterable
-
dotProduct
public long dotProduct(LongList list)
- Specified by:
dotProduct
in interfaceLongList
-
toArray
public long[] toArray()
Description copied from interface:LongIterable
Converts the LongIterable to a primitive long array.- Specified by:
toArray
in interfaceLongIterable
-
toArray
public long[] toArray(long[] target)
Description copied from interface:LongIterable
Converts 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:
toArray
in interfaceLongIterable
-
equals
public boolean equals(java.lang.Object otherList)
Description copied from interface:LongList
Follows the same general contract asList.equals(Object)
.
-
hashCode
public int hashCode()
Description copied from interface:LongList
Follows 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: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
public MutableLongList asUnmodifiable()
- Specified by:
asUnmodifiable
in interfaceMutableLongCollection
- Specified by:
asUnmodifiable
in interfaceMutableLongList
-
asSynchronized
public MutableLongList asSynchronized()
- Specified by:
asSynchronized
in interfaceMutableLongCollection
- Specified by:
asSynchronized
in interfaceMutableLongList
-
toImmutable
public ImmutableLongList toImmutable()
Description copied from interface:MutableLongList
Returns an immutable copy of this list.- Specified by:
toImmutable
in interfaceLongList
- Specified by:
toImmutable
in interfaceMutableLongCollection
- Specified by:
toImmutable
in interfaceMutableLongList
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
- Specified by:
writeExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException
- Specified by:
readExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
-
asReversed
public LazyLongIterable asReversed()
- Specified by:
asReversed
in interfaceReversibleLongIterable
-
reverseThis
public LongArrayList reverseThis()
- Specified by:
reverseThis
in interfaceMutableLongList
-
sortThis
public LongArrayList sortThis()
Description copied from interface:MutableLongList
Sorts this list mutating its contents and returns the same mutable list (this).- Specified by:
sortThis
in interfaceMutableLongList
-
sortThis
public LongArrayList sortThis(LongComparator comparator)
Description copied from interface:MutableLongList
Sorts the internal data structure of this list and returns the list itself as a convenience.- Specified by:
sortThis
in interfaceMutableLongList
-
toReversed
public LongArrayList toReversed()
- Specified by:
toReversed
in interfaceLongList
- Specified by:
toReversed
in interfaceMutableLongList
- Specified by:
toReversed
in interfaceReversibleLongIterable
-
binarySearch
public int binarySearch(long value)
- Specified by:
binarySearch
in interfaceLongList
-
distinct
public MutableLongList distinct()
- Specified by:
distinct
in interfaceLongList
- Specified by:
distinct
in interfaceMutableLongList
- Specified by:
distinct
in interfaceReversibleLongIterable
-
subList
public MutableLongList subList(int fromIndex, int toIndex)
- Specified by:
subList
in interfaceLongList
- Specified by:
subList
in interfaceMutableLongList
- See Also:
List.subList(int fromIndex, int toIndex)
-
zipLong
public MutableList<LongLongPair> zipLong(LongIterable iterable)
Description copied from interface:MutableLongList
Returns aMutableList
formed from thisMutableLongList
and anotherLongList
by combining corresponding elements in pairs. If one of the twoLongList
s is longer than the other, its remaining elements are ignored.- Specified by:
zipLong
in interfaceLongList
- Specified by:
zipLong
in interfaceMutableLongList
- Since:
- 9.1.
-
newEmpty
public LongArrayList newEmpty()
Creates a new empty LongArrayList.- Specified by:
newEmpty
in interfaceMutableLongCollection
- Specified by:
newEmpty
in interfaceMutableLongList
- Since:
- 9.2.
-
zip
public <T> MutableList<LongObjectPair<T>> zip(java.lang.Iterable<T> iterable)
Description copied from interface:MutableLongList
Returns aMutableList
formed from thisMutableLongList
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 interfaceLongList
- Specified by:
zip
in interfaceMutableLongList
- Since:
- 9.1.
-
spliterator
public java.util.Spliterator.OfLong spliterator()
- Specified by:
spliterator
in interfaceLongList
-
-