Class IntArrayList
- java.lang.Object
-
- org.eclipse.collections.impl.primitive.AbstractIntIterable
-
- org.eclipse.collections.impl.list.mutable.primitive.IntArrayList
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,MutableIntCollection,IntIterable,IntList,MutableIntList,OrderedIntIterable,ReversibleIntIterable,PrimitiveIterable
public class IntArrayList extends AbstractIntIterable implements MutableIntList, java.io.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classIntArrayList.InternalIntIterator
-
Field Summary
Fields Modifier and Type Field Description private static int[]DEFAULT_SIZED_EMPTY_ARRAYprotected int[]itemsprivate static intMAXIMUM_ARRAY_SIZEprivate static longserialVersionUIDprotected intsizeprivate static int[]ZERO_SIZED_ARRAY
-
Constructor Summary
Constructors Constructor Description IntArrayList()IntArrayList(int initialCapacity)IntArrayList(int... array)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(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(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.LazyIntIterableasReversed()MutableIntListasSynchronized()MutableIntListasUnmodifiable()intbinarySearch(int value)MutableList<java.lang.Integer>boxed()private voidcheckEmpty()RichIterable<IntIterable>chunk(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 java.util.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)MutableIntListdistinct()longdotProduct(IntList list)voideach(IntProcedure procedure)A synonym for forEach.voidensureCapacity(int minCapacity)private voidensureCapacityForAdd()booleanequals(java.lang.Object otherList)Follows 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)MutableIntIteratorintIterator()Returns a primitive iterator that can be used to iterate over the IntIterable in an imperative style.intlastIndexOf(int value)intmax()intmin()IntArrayListnewEmpty()Creates a new empty IntArrayList.private java.lang.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)voidreadExternal(java.io.ObjectInput in)IntArrayListreject(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)IntArrayListreverseThis()IntArrayListselect(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)IntArrayListsortThis()Sorts this list mutating its contents and returns the same mutable list (this).IntArrayListsortThis(IntComparator comparator)Sorts the internal data structure of this list and returns the list itself as a convenience.java.util.Spliterator.OfIntspliterator()MutableIntListsubList(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.ImmutableIntListtoImmutable()Returns an immutable copy of this list.IntArrayListtoReversed()MutableIntStacktoStack()Converts the collection to a IntStack.private voidtransferItemsToNewArrayWithCapacity(int newCapacity)voidtrimToSize()private voidwipeAndResetTheEnd(int newCurrentFilledIndex)IntArrayListwith(int element)IntArrayListwith(int element1, int element2)IntArrayListwith(int element1, int element2, int element3)IntArrayListwith(int element1, int element2, int element3, int... elements)IntArrayListwithAll(IntIterable elements)private IntArrayListwithArrayCopy(int[] elements, int begin, int length)IntArrayListwithout(int element)IntArrayListwithoutAll(IntIterable elements)static IntArrayListwrapCopy(int... array)Creates a new list by first copying the array passed in.voidwriteExternal(java.io.ObjectOutput out)<T> MutableList<IntObjectPair<T>>zip(java.lang.Iterable<T> iterable)Returns aMutableListformed from thisMutableIntListand aListIterableby combining corresponding elements in pairs.MutableList<IntIntPair>zipInt(IntIterable iterable)Returns aMutableListformed from thisMutableIntListand anotherIntListby combining corresponding elements in pairs.-
Methods inherited from class org.eclipse.collections.impl.primitive.AbstractIntIterable
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.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, toSortedListBy
-
Methods inherited from interface org.eclipse.collections.api.list.primitive.IntList
forEachInBoth, primitiveParallelStream, primitiveStream
-
Methods inherited from interface org.eclipse.collections.api.list.primitive.MutableIntList
collectWithIndex, rejectWithIndex, selectWithIndex, shuffleThis, shuffleThis, sortThisBy, sortThisBy, tap
-
Methods inherited from interface org.eclipse.collections.api.ordered.primitive.OrderedIntIterable
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 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:
- Constant Field Values
-
size
protected int size
-
items
protected transient int[] items
-
-
Method Detail
-
newListWith
public static IntArrayList newListWith(int... 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 IntArrayList newList(IntIterable source)
-
newWithNValues
public static IntArrayList newWithNValues(int size, int value)
-
wrapCopy
public static IntArrayList wrapCopy(int... 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 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
-
newIndexOutOfBoundsException
private java.lang.IndexOutOfBoundsException newIndexOutOfBoundsException(int index)
-
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
public boolean addAll(IntIterable source)
- 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
public boolean addAllAtIndex(int index, IntIterable source)- Specified by:
addAllAtIndexin interfaceMutableIntList
-
shiftElementsAtIndex
private void shiftElementsAtIndex(int index, int sourceSize)
-
remove
public boolean remove(int value)
- Specified by:
removein interfaceMutableIntCollection
-
removeIf
public boolean removeIf(IntPredicate predicate)
- Specified by:
removeIfin interfaceMutableIntCollection
-
wipeAndResetTheEnd
private void wipeAndResetTheEnd(int newCurrentFilledIndex)
-
removeAll
public boolean removeAll(IntIterable source)
- Specified by:
removeAllin interfaceMutableIntCollection
-
removeAll
public boolean removeAll(int... source)
- Specified by:
removeAllin interfaceMutableIntCollection
-
retainAll
public boolean retainAll(IntIterable source)
- Specified by:
retainAllin interfaceMutableIntCollection- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(int... source)
- Specified by:
retainAllin interfaceMutableIntCollection- See Also:
Collection.retainAll(Collection)
-
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
public IntArrayList with(int element)
- Specified by:
within interfaceMutableIntCollection- Specified by:
within interfaceMutableIntList
-
without
public IntArrayList without(int element)
- Specified by:
withoutin interfaceMutableIntCollection- Specified by:
withoutin interfaceMutableIntList
-
withAll
public IntArrayList withAll(IntIterable elements)
- Specified by:
withAllin interfaceMutableIntCollection- Specified by:
withAllin interfaceMutableIntList
-
withoutAll
public IntArrayList withoutAll(IntIterable elements)
- Specified by:
withoutAllin interfaceMutableIntCollection- Specified by:
withoutAllin interfaceMutableIntList
-
with
public IntArrayList with(int element1, int element2)
-
with
public IntArrayList with(int element1, int element2, int element3)
-
with
public IntArrayList with(int element1, int element2, int element3, int... elements)
-
withArrayCopy
private IntArrayList withArrayCopy(int[] elements, int begin, int length)
-
intIterator
public MutableIntIterator 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
public void each(IntProcedure procedure)
Description copied from interface:IntIterableA synonym for forEach.- Specified by:
eachin interfaceIntIterable- Since:
- 7.0.
-
forEachWithIndex
public void forEachWithIndex(IntIntProcedure procedure)
- 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
public RichIterable<IntIterable> chunk(int size)
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
public int count(IntPredicate predicate)
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
public boolean anySatisfy(IntPredicate predicate)
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
public boolean allSatisfy(IntPredicate predicate)
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
public IntArrayList select(IntPredicate predicate)
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
public <R extends MutableIntCollection> R select(IntPredicate predicate, R target)
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
public IntArrayList reject(IntPredicate predicate)
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
public <R extends MutableIntCollection> R reject(IntPredicate predicate, R target)
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
public int detectIfNone(IntPredicate predicate, int ifNone)
- Specified by:
detectIfNonein interfaceIntIterable
-
collect
public <V> MutableList<V> collect(IntToObjectFunction<? extends V> function)
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
public <V,R extends java.util.Collection<V>> R collect(IntToObjectFunction<? extends V> function, R target)
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
public long dotProduct(IntList list)
- 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
public boolean equals(java.lang.Object otherList)
Description copied from interface:IntListFollows the same general contract asList.equals(Object).
-
hashCode
public int hashCode()
Description copied from interface:IntListFollows 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 MutableIntList asUnmodifiable()
- Specified by:
asUnmodifiablein interfaceMutableIntCollection- Specified by:
asUnmodifiablein interfaceMutableIntList
-
asSynchronized
public MutableIntList asSynchronized()
- Specified by:
asSynchronizedin interfaceMutableIntCollection- Specified by:
asSynchronizedin interfaceMutableIntList
-
toImmutable
public ImmutableIntList 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
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 LazyIntIterable asReversed()
- Specified by:
asReversedin interfaceReversibleIntIterable
-
reverseThis
public IntArrayList reverseThis()
- Specified by:
reverseThisin interfaceMutableIntList
-
sortThis
public IntArrayList sortThis()
Description copied from interface:MutableIntListSorts this list mutating its contents and returns the same mutable list (this).- Specified by:
sortThisin interfaceMutableIntList
-
sortThis
public IntArrayList sortThis(IntComparator comparator)
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
public IntArrayList toReversed()
- Specified by:
toReversedin interfaceIntList- Specified by:
toReversedin interfaceMutableIntList- Specified by:
toReversedin interfaceReversibleIntIterable
-
binarySearch
public int binarySearch(int value)
- Specified by:
binarySearchin interfaceIntList
-
distinct
public MutableIntList distinct()
- Specified by:
distinctin interfaceIntList- Specified by:
distinctin interfaceMutableIntList- Specified by:
distinctin interfaceReversibleIntIterable
-
subList
public MutableIntList subList(int fromIndex, int toIndex)
- Specified by:
subListin interfaceIntList- Specified by:
subListin interfaceMutableIntList- See Also:
List.subList(int fromIndex, int toIndex)
-
zipInt
public MutableList<IntIntPair> zipInt(IntIterable iterable)
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
public IntArrayList newEmpty()
Creates a new empty IntArrayList.- Specified by:
newEmptyin interfaceMutableIntCollection- Specified by:
newEmptyin interfaceMutableIntList- Since:
- 9.2.
-
zip
public <T> MutableList<IntObjectPair<T>> zip(java.lang.Iterable<T> iterable)
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
public MutableList<java.lang.Integer> boxed()
- Specified by:
boxedin interfaceMutableIntList
-
toStack
public MutableIntStack toStack()
Description copied from interface:OrderedIntIterableConverts the collection to a IntStack.- Specified by:
toStackin interfaceOrderedIntIterable
-
spliterator
public java.util.Spliterator.OfInt spliterator()
- Specified by:
spliteratorin interfaceIntList
-
-