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
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:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int[]protected int[]private static final intprivate static final longprotected intprivate static final int[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(int newItem) booleanaddAll(int... source) booleanaddAll(IntIterable source) booleanaddAllAtIndex(int index, int... source) booleanaddAllAtIndex(int index, IntIterable source) voidaddAtIndex(int index, int element) private voidaddAtIndexLessThanSize(int index, int element) booleanallSatisfy(IntPredicate predicate) Returns true if all of the elements in the IntIterable return true for the specified predicate, otherwise returns false.booleananySatisfy(IntPredicate predicate) Returns true if any of the elements in the IntIterable 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(int value) boxed()private voidchunk(int size) Partitions elements in fixed size chunks.voidclear()<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.booleancontains(int value) Returns true if the value is contained in the IntIterable, and false if it is not.private voidcopyItems(int sourceSize, int[] source) private int[]copyItemsWithNewCapacity(int newCapacity) intcount(IntPredicate predicate) Returns a count of the number of elements in the IntIterable that return true for the specified predicate.intdetectIfNone(IntPredicate predicate, int ifNone) distinct()longdotProduct(IntList list) voideach(IntProcedure procedure) A synonym for forEach.voidensureCapacity(int minCapacity) private voidbooleanFollows the same general contract asList.equals(Object).voidforEachWithIndex(IntIntProcedure procedure) intget(int index) intgetFirst()intgetLast()inthashCode()Follows the same general contract asList.hashCode().intindexOf(int value) <T> TinjectInto(T injectedValue, ObjectIntToObjectFunction<? super T, ? extends T> function) <T> TinjectIntoWithIndex(T injectedValue, ObjectIntIntToObjectFunction<? super T, ? extends T> function) Returns a primitive iterator that can be used to iterate over the IntIterable in an imperative style.intlastIndexOf(int value) intmax()intmin()newEmpty()Creates a new empty IntArrayList.private IndexOutOfBoundsExceptionnewIndexOutOfBoundsException(int index) static IntArrayListnewList(IntIterable source) static IntArrayListnewListWith(int... elements) Creates a new list using the passedelementsargument as the backing store.static IntArrayListnewWithNValues(int size, int value) voidreject(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.booleanremove(int value) booleanremoveAll(int... source) booleanremoveAll(IntIterable source) intremoveAtIndex(int index) booleanremoveIf(IntPredicate predicate) booleanretainAll(int... source) booleanretainAll(IntIterable source) 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.intset(int index, int 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(IntComparator 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) int[]toArray()Converts the IntIterable to a primitive int array.int[]toArray(int[] target) Converts the IntIterable to a primitive int array.Returns an immutable copy of this list.toStack()Converts the collection to a IntStack.private voidtransferItemsToNewArrayWithCapacity(int newCapacity) voidprivate voidwipeAndResetTheEnd(int newCurrentFilledIndex) with(int element) with(int element1, int element2) with(int element1, int element2, int element3) with(int element1, int element2, int element3, int... elements) withAll(IntIterable elements) private IntArrayListwithArrayCopy(int[] elements, int begin, int length) without(int element) withoutAll(IntIterable elements) static IntArrayListwrapCopy(int... array) Creates a new list by first copying the array passed in.void<T> MutableList<IntObjectPair<T>> Returns aMutableListformed from thisMutableIntListand aListIterableby combining corresponding elements in pairs.zipInt(IntIterable iterable) Returns aMutableListformed from thisMutableIntListand anotherIntListby combining corresponding elements in pairs.Methods inherited from class AbstractIntIterable
asLazy, average, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toStringMethods inherited from interface IntIterable
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 IntList
forEachInBoth, primitiveParallelStream, primitiveStreamMethods inherited from interface MutableIntList
collectWithIndex, rejectWithIndex, selectWithIndex, shuffleThis, shuffleThis, sortThisBy, sortThisBy, tapMethods inherited from interface OrderedIntIterable
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 int[] DEFAULT_SIZED_EMPTY_ARRAY -
ZERO_SIZED_ARRAY
private static final int[] ZERO_SIZED_ARRAY -
MAXIMUM_ARRAY_SIZE
private static final int MAXIMUM_ARRAY_SIZE- See Also:
-
size
protected int size -
items
protected transient int[] items
-
-
Constructor Details
-
IntArrayList
public IntArrayList() -
IntArrayList
public IntArrayList(int initialCapacity) -
IntArrayList
public IntArrayList(int... 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 interfaceMutableIntCollection
-
contains
public boolean contains(int value) Description copied from interface:IntIterableReturns true if the value is contained in the IntIterable, and false if it is not.- Specified by:
containsin interfaceIntIterable
-
get
-
newIndexOutOfBoundsException
-
getFirst
public int getFirst()- Specified by:
getFirstin interfaceOrderedIntIterable
-
getLast
public int getLast()- Specified by:
getLastin interfaceReversibleIntIterable
-
checkEmpty
private void checkEmpty() -
indexOf
public int indexOf(int value) - Specified by:
indexOfin interfaceOrderedIntIterable
-
lastIndexOf
public int lastIndexOf(int value) - Specified by:
lastIndexOfin interfaceIntList
-
trimToSize
public void trimToSize() -
transferItemsToNewArrayWithCapacity
private void transferItemsToNewArrayWithCapacity(int newCapacity) -
copyItemsWithNewCapacity
private int[] copyItemsWithNewCapacity(int newCapacity) -
sizePlusFiftyPercent
private int sizePlusFiftyPercent(int oldSize) -
ensureCapacity
public void ensureCapacity(int minCapacity) -
ensureCapacityForAdd
private void ensureCapacityForAdd() -
add
public boolean add(int newItem) - Specified by:
addin interfaceMutableIntCollection
-
addAll
public boolean addAll(int... source) - Specified by:
addAllin interfaceMutableIntCollection
-
addAll
- Specified by:
addAllin interfaceMutableIntCollection
-
copyItems
private void copyItems(int sourceSize, int[] source) -
throwOutOfBounds
private void throwOutOfBounds(int index) -
addAtIndex
public void addAtIndex(int index, int element) - Specified by:
addAtIndexin interfaceMutableIntList
-
addAtIndexLessThanSize
private void addAtIndexLessThanSize(int index, int element) -
addAllAtIndex
public boolean addAllAtIndex(int index, int... source) - Specified by:
addAllAtIndexin interfaceMutableIntList
-
addAllAtIndex
- Specified by:
addAllAtIndexin interfaceMutableIntList
-
shiftElementsAtIndex
private void shiftElementsAtIndex(int index, int sourceSize) -
remove
public boolean remove(int value) - Specified by:
removein interfaceMutableIntCollection
-
removeIf
- Specified by:
removeIfin interfaceMutableIntCollection
-
wipeAndResetTheEnd
private void wipeAndResetTheEnd(int newCurrentFilledIndex) -
removeAll
- Specified by:
removeAllin interfaceMutableIntCollection
-
removeAll
public boolean removeAll(int... source) - Specified by:
removeAllin interfaceMutableIntCollection
-
retainAll
- Specified by:
retainAllin interfaceMutableIntCollection- See Also:
-
retainAll
public boolean retainAll(int... source) - Specified by:
retainAllin interfaceMutableIntCollection- See Also:
-
removeAtIndex
public int removeAtIndex(int index) - Specified by:
removeAtIndexin interfaceMutableIntList
-
set
public int set(int index, int element) - Specified by:
setin interfaceMutableIntList
-
swap
public void swap(int index1, int index2) - Specified by:
swapin interfaceMutableIntList
-
with
- Specified by:
within interfaceMutableIntCollection- Specified by:
within interfaceMutableIntList
-
without
- Specified by:
withoutin interfaceMutableIntCollection- Specified by:
withoutin interfaceMutableIntList
-
withAll
- Specified by:
withAllin interfaceMutableIntCollection- Specified by:
withAllin interfaceMutableIntList
-
withoutAll
- Specified by:
withoutAllin interfaceMutableIntCollection- Specified by:
withoutAllin interfaceMutableIntList
-
with
-
with
-
with
-
withArrayCopy
-
intIterator
Description copied from interface:IntIterableReturns a primitive iterator that can be used to iterate over the IntIterable in an imperative style.- Specified by:
intIteratorin interfaceIntIterable- Specified by:
intIteratorin interfaceMutableIntCollection
-
each
Description copied from interface:IntIterableA synonym for forEach.- Specified by:
eachin interfaceIntIterable- Since:
- 7.0.
-
forEachWithIndex
- Specified by:
forEachWithIndexin interfaceOrderedIntIterable
-
injectInto
public <T> T injectInto(T injectedValue, ObjectIntToObjectFunction<? super T, ? extends T> function) - Specified by:
injectIntoin interfaceIntIterable
-
injectIntoWithIndex
public <T> T injectIntoWithIndex(T injectedValue, ObjectIntIntToObjectFunction<? super T, ? extends T> function) - Specified by:
injectIntoWithIndexin interfaceOrderedIntIterable- Specified by:
injectIntoWithIndexin interfaceReversibleIntIterable
-
chunk
Description copied from interface:IntIterablePartitions elements in fixed size chunks.- Specified by:
chunkin interfaceIntIterable- Parameters:
size- the number of elements per chunk- Returns:
- A
RichIterablecontainingIntIterables of sizesize, except the last will be truncated if the elements don't divide evenly.
-
count
Description copied from interface:IntIterableReturns a count of the number of elements in the IntIterable that return true for the specified predicate.- Specified by:
countin interfaceIntIterable
-
anySatisfy
Description copied from interface:IntIterableReturns true if any of the elements in the IntIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfyin interfaceIntIterable
-
allSatisfy
Description copied from interface:IntIterableReturns true if all of the elements in the IntIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfyin interfaceIntIterable
-
select
Description copied from interface:IntIterableReturns a new IntIterable with all of the elements in the IntIterable that return true for the specified predicate.- Specified by:
selectin interfaceIntIterable- Specified by:
selectin interfaceIntList- Specified by:
selectin interfaceMutableIntCollection- Specified by:
selectin interfaceMutableIntList- Specified by:
selectin interfaceOrderedIntIterable- Specified by:
selectin interfaceReversibleIntIterable
-
select
Description copied from interface:IntIterableSame asIntIterable.select(IntPredicate), only the results are added to the target MutableIntCollection.- Specified by:
selectin interfaceIntIterable- Since:
- 8.1.
-
reject
Description copied from interface:IntIterableReturns a new IntIterable with all of the elements in the IntIterable that return false for the specified predicate.- Specified by:
rejectin interfaceIntIterable- Specified by:
rejectin interfaceIntList- Specified by:
rejectin interfaceMutableIntCollection- Specified by:
rejectin interfaceMutableIntList- Specified by:
rejectin interfaceOrderedIntIterable- Specified by:
rejectin interfaceReversibleIntIterable
-
reject
Description copied from interface:IntIterableSame asIntIterable.reject(IntPredicate), only the results are added to the target MutableIntCollection.- Specified by:
rejectin interfaceIntIterable- Since:
- 8.1.
-
detectIfNone
- Specified by:
detectIfNonein interfaceIntIterable
-
collect
Description copied from interface:IntIterableReturns 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 interfaceIntIterable- Specified by:
collectin interfaceIntList- Specified by:
collectin interfaceMutableIntCollection- Specified by:
collectin interfaceMutableIntList- Specified by:
collectin interfaceOrderedIntIterable- Specified by:
collectin interfaceReversibleIntIterable
-
collect
Description copied from interface:IntIterableSame asIntIterable.collect(IntToObjectFunction), only the results are added to the target Collection.- Specified by:
collectin interfaceIntIterable- Since:
- 8.1.
-
max
public int max()- Specified by:
maxin interfaceIntIterable
-
min
public int min()- Specified by:
minin interfaceIntIterable
-
sum
public long sum()- Specified by:
sumin interfaceIntIterable
-
dotProduct
- Specified by:
dotProductin interfaceIntList
-
toArray
public int[] toArray()Description copied from interface:IntIterableConverts the IntIterable to a primitive int array.- Specified by:
toArrayin interfaceIntIterable
-
toArray
public int[] toArray(int[] target) Description copied from interface:IntIterableConverts 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:
toArrayin interfaceIntIterable
-
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 interfaceMutableIntCollection- Specified by:
asUnmodifiablein interfaceMutableIntList
-
asSynchronized
- Specified by:
asSynchronizedin interfaceMutableIntCollection- Specified by:
asSynchronizedin interfaceMutableIntList
-
toImmutable
Description copied from interface:MutableIntListReturns an immutable copy of this list.- Specified by:
toImmutablein interfaceIntList- Specified by:
toImmutablein interfaceMutableIntCollection- Specified by:
toImmutablein interfaceMutableIntList
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOException
-
asReversed
- Specified by:
asReversedin interfaceReversibleIntIterable
-
reverseThis
- Specified by:
reverseThisin interfaceMutableIntList
-
sortThis
Description copied from interface:MutableIntListSorts this list mutating its contents and returns the same mutable list (this).- Specified by:
sortThisin interfaceMutableIntList
-
sortThis
Description copied from interface:MutableIntListSorts the internal data structure of this list and returns the list itself as a convenience.- Specified by:
sortThisin interfaceMutableIntList
-
toReversed
- Specified by:
toReversedin interfaceIntList- Specified by:
toReversedin interfaceMutableIntList- Specified by:
toReversedin interfaceReversibleIntIterable
-
binarySearch
public int binarySearch(int value) - Specified by:
binarySearchin interfaceIntList
-
distinct
- Specified by:
distinctin interfaceIntList- Specified by:
distinctin interfaceMutableIntList- Specified by:
distinctin interfaceReversibleIntIterable
-
subList
- Specified by:
subListin interfaceIntList- Specified by:
subListin interfaceMutableIntList- See Also:
-
zipInt
Description copied from interface:MutableIntListReturns aMutableListformed from thisMutableIntListand anotherIntListby combining corresponding elements in pairs. If one of the twoIntLists is longer than the other, its remaining elements are ignored.- Specified by:
zipIntin interfaceIntList- Specified by:
zipIntin interfaceMutableIntList- Since:
- 9.1.
-
newEmpty
Creates a new empty IntArrayList.- Specified by:
newEmptyin interfaceMutableIntCollection- Specified by:
newEmptyin interfaceMutableIntList- Since:
- 9.2.
-
zip
Description copied from interface:MutableIntListReturns aMutableListformed from thisMutableIntListand 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 interfaceIntList- Specified by:
zipin interfaceMutableIntList- Since:
- 9.1.
-
boxed
- Specified by:
boxedin interfaceMutableIntList
-
toStack
Description copied from interface:OrderedIntIterableConverts the collection to a IntStack.- Specified by:
toStackin interfaceOrderedIntIterable
-
spliterator
- Specified by:
spliteratorin interfaceIntList
-