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
public class LongArrayList extends AbstractLongIterable implements MutableLongList, 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
-
Constructor Summary
Constructors Constructor Description LongArrayList()
LongArrayList(int initialCapacity)
LongArrayList(long... array)
-
Method Summary
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)
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(Appendable appendable, String start, String separator, String end)
Prints a string representation of this collection onto the givenAppendable
.LazyLongIterable
asReversed()
MutableLongList
asSynchronized()
MutableLongList
asUnmodifiable()
int
binarySearch(long value)
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 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.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)
boolean
equals(Object otherList)
Follows the same general contract asList.equals(Object)
.void
forEach(LongProcedure procedure)
Applies the LongProcedure to each element in the LongIterable.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.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)
boolean
noneSatisfy(LongPredicate predicate)
Returns true if none of the elements in the LongIterable return true for the specified predicate, otherwise returns false.void
readExternal(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)
int
size()
Returns the number of items in this iterable.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.Spliterator.OfLong
spliterator()
MutableLongList
subList(int fromIndex, int toIndex)
long
sum()
void
swap(int index1, int index2)
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()
void
trimToSize()
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)
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(ObjectOutput out)
<T> MutableList<LongObjectPair<T>>
zip(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, containsAll, containsAll, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toString
Methods inherited from interface org.eclipse.collections.api.LongIterable
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.LongList
primitiveParallelStream, primitiveStream
Methods inherited from interface org.eclipse.collections.api.list.primitive.MutableLongList
collectWithIndex, shuffleThis, shuffleThis, sortThisBy, sortThisBy, tap
Methods inherited from interface org.eclipse.collections.api.ordered.primitive.OrderedLongIterable
collectWithIndex
Methods inherited from interface org.eclipse.collections.api.PrimitiveIterable
appendString, appendString, isEmpty, makeString, makeString, makeString, notEmpty, toString
-
Constructor Details
-
LongArrayList
public LongArrayList() -
LongArrayList
public LongArrayList(int initialCapacity) -
LongArrayList
public LongArrayList(long... 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 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
-
get
public long get(int index) -
getFirst
public long getFirst()- Specified by:
getFirst
in interfaceOrderedLongIterable
-
getLast
public long getLast()- Specified by:
getLast
in interfaceReversibleLongIterable
-
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() -
ensureCapacity
public void ensureCapacity(int minCapacity) -
add
public boolean add(long newItem)- Specified by:
add
in interfaceMutableLongCollection
-
addAll
public boolean addAll(long... source)- Specified by:
addAll
in interfaceMutableLongCollection
-
addAll
- Specified by:
addAll
in interfaceMutableLongCollection
-
addAtIndex
public void addAtIndex(int index, long element)- Specified by:
addAtIndex
in interfaceMutableLongList
-
addAllAtIndex
public boolean addAllAtIndex(int index, long... source)- Specified by:
addAllAtIndex
in interfaceMutableLongList
-
addAllAtIndex
- Specified by:
addAllAtIndex
in interfaceMutableLongList
-
remove
public boolean remove(long value)- Specified by:
remove
in interfaceMutableLongCollection
-
removeIf
- Specified by:
removeIf
in interfaceMutableLongCollection
-
removeAll
- Specified by:
removeAll
in interfaceMutableLongCollection
-
removeAll
public boolean removeAll(long... source)- Specified by:
removeAll
in interfaceMutableLongCollection
-
retainAll
- 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
- Specified by:
with
in interfaceMutableLongCollection
- Specified by:
with
in interfaceMutableLongList
-
without
- Specified by:
without
in interfaceMutableLongCollection
- Specified by:
without
in interfaceMutableLongList
-
withAll
- Specified by:
withAll
in interfaceMutableLongCollection
- Specified by:
withAll
in interfaceMutableLongList
-
withoutAll
- Specified by:
withoutAll
in interfaceMutableLongCollection
- Specified by:
withoutAll
in interfaceMutableLongList
-
with
-
with
-
with
-
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
-
forEach
Description copied from interface:LongIterable
Applies the LongProcedure to each element in the LongIterable.- Specified by:
forEach
in interfaceLongIterable
-
each
Description copied from interface:LongIterable
A synonym for forEach.- Specified by:
each
in interfaceLongIterable
- Since:
- 7.0.
-
forEachWithIndex
- 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
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
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
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
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
-
noneSatisfy
Description copied from interface:LongIterable
Returns true if none of the elements in the LongIterable return true for the specified predicate, otherwise returns false.- Specified by:
noneSatisfy
in interfaceLongIterable
-
select
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
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
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
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
- Specified by:
detectIfNone
in interfaceLongIterable
-
collect
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 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
- 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
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
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 interfaceMutableLongCollection
- Specified by:
asUnmodifiable
in interfaceMutableLongList
-
asSynchronized
- Specified by:
asSynchronized
in interfaceMutableLongCollection
- Specified by:
asSynchronized
in interfaceMutableLongList
-
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
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
-
asReversed
- Specified by:
asReversed
in interfaceReversibleLongIterable
-
reverseThis
- Specified by:
reverseThis
in interfaceMutableLongList
-
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
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
- 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
- Specified by:
distinct
in interfaceLongList
- Specified by:
distinct
in interfaceMutableLongList
- Specified by:
distinct
in interfaceReversibleLongIterable
-
subList
- Specified by:
subList
in interfaceLongList
- Specified by:
subList
in interfaceMutableLongList
- See Also:
List.subList(int fromIndex, int toIndex)
-
zipLong
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
Creates a new empty LongArrayList.- Specified by:
newEmpty
in interfaceMutableLongCollection
- Specified by:
newEmpty
in interfaceMutableLongList
- Since:
- 9.2.
-
zip
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
- Specified by:
spliterator
in interfaceLongList
-