Class IntArrayList
java.lang.Object
org.eclipse.collections.impl.primitive.AbstractIntIterable
org.eclipse.collections.impl.list.mutable.primitive.IntArrayList
- All Implemented Interfaces:
Externalizable
,Serializable
,MutableIntCollection
,IntIterable
,IntList
,MutableIntList
,OrderedIntIterable
,ReversibleIntIterable
,PrimitiveIterable
public class IntArrayList extends AbstractIntIterable implements MutableIntList, Externalizable
IntArrayList is similar to
FastList
, and is memory-optimized for int primitives.
This file was automatically generated from template file primitiveArrayList.stg.- Since:
- 3.0.
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description IntArrayList()
IntArrayList(int initialCapacity)
IntArrayList(int... array)
-
Method Summary
Modifier and Type Method Description boolean
add(int newItem)
boolean
addAll(int... source)
boolean
addAll(IntIterable source)
boolean
addAllAtIndex(int index, int... source)
boolean
addAllAtIndex(int index, IntIterable source)
void
addAtIndex(int index, int element)
boolean
allSatisfy(IntPredicate predicate)
Returns true if all of the elements in the IntIterable return true for the specified predicate, otherwise returns false.boolean
anySatisfy(IntPredicate predicate)
Returns true if any of the elements in the IntIterable 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
.LazyIntIterable
asReversed()
MutableIntList
asSynchronized()
MutableIntList
asUnmodifiable()
int
binarySearch(int value)
RichIterable<IntIterable>
chunk(int size)
Partitions elements in fixed size chunks.void
clear()
<V> MutableList<V>
collect(IntToObjectFunction<? 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(IntToObjectFunction<? extends V> function, R target)
Same asIntIterable.collect(IntToObjectFunction)
, only the results are added to the target Collection.boolean
contains(int value)
Returns true if the value is contained in the IntIterable, and false if it is not.int
count(IntPredicate predicate)
Returns a count of the number of elements in the IntIterable that return true for the specified predicate.int
detectIfNone(IntPredicate predicate, int ifNone)
MutableIntList
distinct()
long
dotProduct(IntList list)
void
each(IntProcedure procedure)
A synonym for forEach.void
ensureCapacity(int minCapacity)
boolean
equals(Object otherList)
Follows the same general contract asList.equals(Object)
.void
forEach(IntProcedure procedure)
Applies the IntProcedure to each element in the IntIterable.void
forEachWithIndex(IntIntProcedure procedure)
int
get(int index)
int
getFirst()
int
getLast()
int
hashCode()
Follows the same general contract asList.hashCode()
.int
indexOf(int value)
<T> T
injectInto(T injectedValue, ObjectIntToObjectFunction<? super T,? extends T> function)
<T> T
injectIntoWithIndex(T injectedValue, ObjectIntIntToObjectFunction<? super T,? extends T> function)
MutableIntIterator
intIterator()
Returns a primitive iterator that can be used to iterate over the IntIterable in an imperative style.int
lastIndexOf(int value)
int
max()
int
min()
IntArrayList
newEmpty()
Creates a new empty IntArrayList.static IntArrayList
newList(IntIterable source)
static IntArrayList
newListWith(int... elements)
Creates a new list using the passedelements
argument as the backing store.static IntArrayList
newWithNValues(int size, int value)
boolean
noneSatisfy(IntPredicate predicate)
Returns true if none of the elements in the IntIterable return true for the specified predicate, otherwise returns false.void
readExternal(ObjectInput in)
IntArrayList
reject(IntPredicate predicate)
Returns a new IntIterable with all of the elements in the IntIterable that return false for the specified predicate.<R extends MutableIntCollection>
Rreject(IntPredicate predicate, R target)
Same asIntIterable.reject(IntPredicate)
, only the results are added to the target MutableIntCollection.boolean
remove(int value)
boolean
removeAll(int... source)
boolean
removeAll(IntIterable source)
int
removeAtIndex(int index)
boolean
removeIf(IntPredicate predicate)
boolean
retainAll(int... source)
boolean
retainAll(IntIterable source)
IntArrayList
reverseThis()
IntArrayList
select(IntPredicate predicate)
Returns a new IntIterable with all of the elements in the IntIterable that return true for the specified predicate.<R extends MutableIntCollection>
Rselect(IntPredicate predicate, R target)
Same asIntIterable.select(IntPredicate)
, only the results are added to the target MutableIntCollection.int
set(int index, int element)
int
size()
Returns the number of items in this iterable.IntArrayList
sortThis()
Sorts this list mutating its contents and returns the same mutable list (this).IntArrayList
sortThis(IntComparator comparator)
Sorts the internal data structure of this list and returns the list itself as a convenience.Spliterator.OfInt
spliterator()
MutableIntList
subList(int fromIndex, int toIndex)
long
sum()
void
swap(int index1, int index2)
int[]
toArray()
Converts the IntIterable to a primitive int array.int[]
toArray(int[] target)
Converts the IntIterable to a primitive int array.ImmutableIntList
toImmutable()
Returns an immutable copy of this list.IntArrayList
toReversed()
void
trimToSize()
IntArrayList
with(int element)
IntArrayList
with(int element1, int element2)
IntArrayList
with(int element1, int element2, int element3)
IntArrayList
with(int element1, int element2, int element3, int... elements)
IntArrayList
withAll(IntIterable elements)
IntArrayList
without(int element)
IntArrayList
withoutAll(IntIterable elements)
static IntArrayList
wrapCopy(int... array)
Creates a new list by first copying the array passed in.void
writeExternal(ObjectOutput out)
<T> MutableList<IntObjectPair<T>>
zip(Iterable<T> iterable)
Returns aMutableList
formed from thisMutableIntList
and aListIterable
by combining corresponding elements in pairs.MutableList<IntIntPair>
zipInt(IntIterable iterable)
Returns aMutableList
formed from thisMutableIntList
and anotherIntList
by combining corresponding elements in pairs.Methods inherited from class org.eclipse.collections.impl.primitive.AbstractIntIterable
asLazy, average, containsAll, containsAll, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toString
Methods inherited from interface org.eclipse.collections.api.IntIterable
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.IntList
primitiveParallelStream, primitiveStream
Methods inherited from interface org.eclipse.collections.api.list.primitive.MutableIntList
collectWithIndex, shuffleThis, shuffleThis, sortThisBy, sortThisBy, tap
Methods inherited from interface org.eclipse.collections.api.ordered.primitive.OrderedIntIterable
collectWithIndex
Methods inherited from interface org.eclipse.collections.api.PrimitiveIterable
appendString, appendString, isEmpty, makeString, makeString, makeString, notEmpty, toString
-
Constructor Details
-
IntArrayList
public IntArrayList() -
IntArrayList
public IntArrayList(int initialCapacity) -
IntArrayList
public IntArrayList(int... 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 interfaceMutableIntCollection
-
contains
public boolean contains(int value)Description copied from interface:IntIterable
Returns true if the value is contained in the IntIterable, and false if it is not.- Specified by:
contains
in interfaceIntIterable
-
get
public int get(int index) -
getFirst
public int getFirst()- Specified by:
getFirst
in interfaceOrderedIntIterable
-
getLast
public int getLast()- Specified by:
getLast
in interfaceReversibleIntIterable
-
indexOf
public int indexOf(int value)- Specified by:
indexOf
in interfaceOrderedIntIterable
-
lastIndexOf
public int lastIndexOf(int value)- Specified by:
lastIndexOf
in interfaceIntList
-
trimToSize
public void trimToSize() -
ensureCapacity
public void ensureCapacity(int minCapacity) -
add
public boolean add(int newItem)- Specified by:
add
in interfaceMutableIntCollection
-
addAll
public boolean addAll(int... source)- Specified by:
addAll
in interfaceMutableIntCollection
-
addAll
- Specified by:
addAll
in interfaceMutableIntCollection
-
addAtIndex
public void addAtIndex(int index, int element)- Specified by:
addAtIndex
in interfaceMutableIntList
-
addAllAtIndex
public boolean addAllAtIndex(int index, int... source)- Specified by:
addAllAtIndex
in interfaceMutableIntList
-
addAllAtIndex
- Specified by:
addAllAtIndex
in interfaceMutableIntList
-
remove
public boolean remove(int value)- Specified by:
remove
in interfaceMutableIntCollection
-
removeIf
- Specified by:
removeIf
in interfaceMutableIntCollection
-
removeAll
- Specified by:
removeAll
in interfaceMutableIntCollection
-
removeAll
public boolean removeAll(int... source)- Specified by:
removeAll
in interfaceMutableIntCollection
-
retainAll
- Specified by:
retainAll
in interfaceMutableIntCollection
- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(int... source)- Specified by:
retainAll
in interfaceMutableIntCollection
- See Also:
Collection.retainAll(Collection)
-
removeAtIndex
public int removeAtIndex(int index)- Specified by:
removeAtIndex
in interfaceMutableIntList
-
set
public int set(int index, int element)- Specified by:
set
in interfaceMutableIntList
-
swap
public void swap(int index1, int index2)- Specified by:
swap
in interfaceMutableIntList
-
with
- Specified by:
with
in interfaceMutableIntCollection
- Specified by:
with
in interfaceMutableIntList
-
without
- Specified by:
without
in interfaceMutableIntCollection
- Specified by:
without
in interfaceMutableIntList
-
withAll
- Specified by:
withAll
in interfaceMutableIntCollection
- Specified by:
withAll
in interfaceMutableIntList
-
withoutAll
- Specified by:
withoutAll
in interfaceMutableIntCollection
- Specified by:
withoutAll
in interfaceMutableIntList
-
with
-
with
-
with
-
intIterator
Description copied from interface:IntIterable
Returns a primitive iterator that can be used to iterate over the IntIterable in an imperative style.- Specified by:
intIterator
in interfaceIntIterable
- Specified by:
intIterator
in interfaceMutableIntCollection
-
forEach
Description copied from interface:IntIterable
Applies the IntProcedure to each element in the IntIterable.- Specified by:
forEach
in interfaceIntIterable
-
each
Description copied from interface:IntIterable
A synonym for forEach.- Specified by:
each
in interfaceIntIterable
- Since:
- 7.0.
-
forEachWithIndex
- Specified by:
forEachWithIndex
in interfaceOrderedIntIterable
-
injectInto
public <T> T injectInto(T injectedValue, ObjectIntToObjectFunction<? super T,? extends T> function)- Specified by:
injectInto
in interfaceIntIterable
-
injectIntoWithIndex
public <T> T injectIntoWithIndex(T injectedValue, ObjectIntIntToObjectFunction<? super T,? extends T> function)- Specified by:
injectIntoWithIndex
in interfaceOrderedIntIterable
- Specified by:
injectIntoWithIndex
in interfaceReversibleIntIterable
-
chunk
Description copied from interface:IntIterable
Partitions elements in fixed size chunks.- Specified by:
chunk
in interfaceIntIterable
- Parameters:
size
- the number of elements per chunk- Returns:
- A
RichIterable
containingIntIterable
s of sizesize
, except the last will be truncated if the elements don't divide evenly.
-
count
Description copied from interface:IntIterable
Returns a count of the number of elements in the IntIterable that return true for the specified predicate.- Specified by:
count
in interfaceIntIterable
-
anySatisfy
Description copied from interface:IntIterable
Returns true if any of the elements in the IntIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfy
in interfaceIntIterable
-
allSatisfy
Description copied from interface:IntIterable
Returns true if all of the elements in the IntIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfy
in interfaceIntIterable
-
noneSatisfy
Description copied from interface:IntIterable
Returns true if none of the elements in the IntIterable return true for the specified predicate, otherwise returns false.- Specified by:
noneSatisfy
in interfaceIntIterable
-
select
Description copied from interface:IntIterable
Returns a new IntIterable with all of the elements in the IntIterable that return true for the specified predicate.- Specified by:
select
in interfaceIntIterable
- Specified by:
select
in interfaceIntList
- Specified by:
select
in interfaceMutableIntCollection
- Specified by:
select
in interfaceMutableIntList
- Specified by:
select
in interfaceOrderedIntIterable
- Specified by:
select
in interfaceReversibleIntIterable
-
select
Description copied from interface:IntIterable
Same asIntIterable.select(IntPredicate)
, only the results are added to the target MutableIntCollection.- Specified by:
select
in interfaceIntIterable
- Since:
- 8.1.
-
reject
Description copied from interface:IntIterable
Returns a new IntIterable with all of the elements in the IntIterable that return false for the specified predicate.- Specified by:
reject
in interfaceIntIterable
- Specified by:
reject
in interfaceIntList
- Specified by:
reject
in interfaceMutableIntCollection
- Specified by:
reject
in interfaceMutableIntList
- Specified by:
reject
in interfaceOrderedIntIterable
- Specified by:
reject
in interfaceReversibleIntIterable
-
reject
Description copied from interface:IntIterable
Same asIntIterable.reject(IntPredicate)
, only the results are added to the target MutableIntCollection.- Specified by:
reject
in interfaceIntIterable
- Since:
- 8.1.
-
detectIfNone
- Specified by:
detectIfNone
in interfaceIntIterable
-
collect
Description copied from interface:IntIterable
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 interfaceIntIterable
- Specified by:
collect
in interfaceIntList
- Specified by:
collect
in interfaceMutableIntCollection
- Specified by:
collect
in interfaceMutableIntList
- Specified by:
collect
in interfaceOrderedIntIterable
- Specified by:
collect
in interfaceReversibleIntIterable
-
collect
public <V, R extends Collection<V>> R collect(IntToObjectFunction<? extends V> function, R target)Description copied from interface:IntIterable
Same asIntIterable.collect(IntToObjectFunction)
, only the results are added to the target Collection.- Specified by:
collect
in interfaceIntIterable
- Since:
- 8.1.
-
max
public int max()- Specified by:
max
in interfaceIntIterable
-
min
public int min()- Specified by:
min
in interfaceIntIterable
-
sum
public long sum()- Specified by:
sum
in interfaceIntIterable
-
dotProduct
- Specified by:
dotProduct
in interfaceIntList
-
toArray
public int[] toArray()Description copied from interface:IntIterable
Converts the IntIterable to a primitive int array.- Specified by:
toArray
in interfaceIntIterable
-
toArray
public int[] toArray(int[] target)Description copied from interface:IntIterable
Converts the IntIterable to a primitive int 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 interfaceIntIterable
-
equals
Description copied from interface:IntList
Follows the same general contract asList.equals(Object)
. -
hashCode
public int hashCode()Description copied from interface:IntList
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 interfaceMutableIntCollection
- Specified by:
asUnmodifiable
in interfaceMutableIntList
-
asSynchronized
- Specified by:
asSynchronized
in interfaceMutableIntCollection
- Specified by:
asSynchronized
in interfaceMutableIntList
-
toImmutable
Description copied from interface:MutableIntList
Returns an immutable copy of this list.- Specified by:
toImmutable
in interfaceIntList
- Specified by:
toImmutable
in interfaceMutableIntCollection
- Specified by:
toImmutable
in interfaceMutableIntList
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
-
asReversed
- Specified by:
asReversed
in interfaceReversibleIntIterable
-
reverseThis
- Specified by:
reverseThis
in interfaceMutableIntList
-
sortThis
Description copied from interface:MutableIntList
Sorts this list mutating its contents and returns the same mutable list (this).- Specified by:
sortThis
in interfaceMutableIntList
-
sortThis
Description copied from interface:MutableIntList
Sorts the internal data structure of this list and returns the list itself as a convenience.- Specified by:
sortThis
in interfaceMutableIntList
-
toReversed
- Specified by:
toReversed
in interfaceIntList
- Specified by:
toReversed
in interfaceMutableIntList
- Specified by:
toReversed
in interfaceReversibleIntIterable
-
binarySearch
public int binarySearch(int value)- Specified by:
binarySearch
in interfaceIntList
-
distinct
- Specified by:
distinct
in interfaceIntList
- Specified by:
distinct
in interfaceMutableIntList
- Specified by:
distinct
in interfaceReversibleIntIterable
-
subList
- Specified by:
subList
in interfaceIntList
- Specified by:
subList
in interfaceMutableIntList
- See Also:
List.subList(int fromIndex, int toIndex)
-
zipInt
Description copied from interface:MutableIntList
Returns aMutableList
formed from thisMutableIntList
and anotherIntList
by combining corresponding elements in pairs. If one of the twoIntList
s is longer than the other, its remaining elements are ignored.- Specified by:
zipInt
in interfaceIntList
- Specified by:
zipInt
in interfaceMutableIntList
- Since:
- 9.1.
-
newEmpty
Creates a new empty IntArrayList.- Specified by:
newEmpty
in interfaceMutableIntCollection
- Specified by:
newEmpty
in interfaceMutableIntList
- Since:
- 9.2.
-
zip
Description copied from interface:MutableIntList
Returns aMutableList
formed from thisMutableIntList
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 interfaceIntList
- Specified by:
zip
in interfaceMutableIntList
- Since:
- 9.1.
-
spliterator
- Specified by:
spliterator
in interfaceIntList
-