Class ShortArrayList
- java.lang.Object
-
- org.eclipse.collections.impl.primitive.AbstractShortIterable
-
- org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,MutableShortCollection,MutableShortList,ShortList,OrderedShortIterable,ReversibleShortIterable,PrimitiveIterable,ShortIterable
public class ShortArrayList extends AbstractShortIterable implements MutableShortList, java.io.Externalizable
ShortArrayList is similar to FastList, and is memory-optimized for short 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 classShortArrayList.InternalShortIterator
-
Field Summary
Fields Modifier and Type Field Description private static short[]DEFAULT_SIZED_EMPTY_ARRAYprotected short[]itemsprivate static intMAXIMUM_ARRAY_SIZEprivate static longserialVersionUIDprotected intsizeprivate static short[]ZERO_SIZED_ARRAY
-
Constructor Summary
Constructors Constructor Description ShortArrayList()ShortArrayList(int initialCapacity)ShortArrayList(short... array)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(short newItem)booleanaddAll(short... source)booleanaddAll(ShortIterable source)booleanaddAllAtIndex(int index, short... source)booleanaddAllAtIndex(int index, ShortIterable source)voidaddAtIndex(int index, short element)private voidaddAtIndexLessThanSize(int index, short element)booleanallSatisfy(ShortPredicate predicate)Returns true if all of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.booleananySatisfy(ShortPredicate predicate)Returns true if any of the elements in the ShortIterable 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.LazyShortIterableasReversed()MutableShortListasSynchronized()MutableShortListasUnmodifiable()intbinarySearch(short value)MutableList<java.lang.Short>boxed()private voidcheckEmpty()RichIterable<ShortIterable>chunk(int size)Partitions elements in fixed size chunks.voidclear()<V> MutableList<V>collect(ShortToObjectFunction<? 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(ShortToObjectFunction<? extends V> function, R target)Same asShortIterable.collect(ShortToObjectFunction), only the results are added to the target Collection.booleancontains(short value)Returns true if the value is contained in the ShortIterable, and false if it is not.private voidcopyItems(int sourceSize, short[] source)private short[]copyItemsWithNewCapacity(int newCapacity)intcount(ShortPredicate predicate)Returns a count of the number of elements in the ShortIterable that return true for the specified predicate.shortdetectIfNone(ShortPredicate predicate, short ifNone)MutableShortListdistinct()longdotProduct(ShortList list)voideach(ShortProcedure procedure)A synonym for forEach.voidensureCapacity(int minCapacity)private voidensureCapacityForAdd()booleanequals(java.lang.Object otherList)Follows the same general contract asList.equals(Object).voidforEachWithIndex(ShortIntProcedure procedure)shortget(int index)shortgetFirst()shortgetLast()inthashCode()Follows the same general contract asList.hashCode().intindexOf(short value)<T> TinjectInto(T injectedValue, ObjectShortToObjectFunction<? super T,? extends T> function)<T> TinjectIntoWithIndex(T injectedValue, ObjectShortIntToObjectFunction<? super T,? extends T> function)intlastIndexOf(short value)shortmax()shortmin()ShortArrayListnewEmpty()Creates a new empty ShortArrayList.private java.lang.IndexOutOfBoundsExceptionnewIndexOutOfBoundsException(int index)static ShortArrayListnewList(ShortIterable source)static ShortArrayListnewListWith(short... elements)Creates a new list using the passedelementsargument as the backing store.static ShortArrayListnewWithNValues(int size, short value)voidreadExternal(java.io.ObjectInput in)ShortArrayListreject(ShortPredicate predicate)Returns a new ShortIterable with all of the elements in the ShortIterable that return false for the specified predicate.<R extends MutableShortCollection>
Rreject(ShortPredicate predicate, R target)Same asShortIterable.reject(ShortPredicate), only the results are added to the target MutableShortCollection.booleanremove(short value)booleanremoveAll(short... source)booleanremoveAll(ShortIterable source)shortremoveAtIndex(int index)booleanremoveIf(ShortPredicate predicate)booleanretainAll(short... source)booleanretainAll(ShortIterable source)ShortArrayListreverseThis()ShortArrayListselect(ShortPredicate predicate)Returns a new ShortIterable with all of the elements in the ShortIterable that return true for the specified predicate.<R extends MutableShortCollection>
Rselect(ShortPredicate predicate, R target)Same asShortIterable.select(ShortPredicate), only the results are added to the target MutableShortCollection.shortset(int index, short element)private voidshiftElementsAtIndex(int index, int sourceSize)MutableShortIteratorshortIterator()Returns a primitive iterator that can be used to iterate over the ShortIterable in an imperative style.intsize()Returns the number of items in this iterable.private intsizePlusFiftyPercent(int oldSize)ShortArrayListsortThis()Sorts this list mutating its contents and returns the same mutable list (this).ShortArrayListsortThis(ShortComparator comparator)Sorts the internal data structure of this list and returns the list itself as a convenience.MutableShortListsubList(int fromIndex, int toIndex)longsum()voidswap(int index1, int index2)private voidthrowOutOfBounds(int index)short[]toArray()Converts the ShortIterable to a primitive short array.short[]toArray(short[] target)Converts the ShortIterable to a primitive short array.ImmutableShortListtoImmutable()Returns an immutable copy of this list.ShortArrayListtoReversed()MutableShortStacktoStack()Converts the collection to a ShortStack.private voidtransferItemsToNewArrayWithCapacity(int newCapacity)voidtrimToSize()private voidwipeAndResetTheEnd(int newCurrentFilledIndex)ShortArrayListwith(short element)ShortArrayListwith(short element1, short element2)ShortArrayListwith(short element1, short element2, short element3)ShortArrayListwith(short element1, short element2, short element3, short... elements)ShortArrayListwithAll(ShortIterable elements)private ShortArrayListwithArrayCopy(short[] elements, int begin, int length)ShortArrayListwithout(short element)ShortArrayListwithoutAll(ShortIterable elements)static ShortArrayListwrapCopy(short... array)Creates a new list by first copying the array passed in.voidwriteExternal(java.io.ObjectOutput out)<T> MutableList<ShortObjectPair<T>>zip(java.lang.Iterable<T> iterable)Returns aMutableListformed from thisMutableShortListand aListIterableby combining corresponding elements in pairs.MutableList<ShortShortPair>zipShort(ShortIterable iterable)Returns aMutableListformed from thisMutableShortListand anotherShortListby combining corresponding elements in pairs.-
Methods inherited from class org.eclipse.collections.impl.primitive.AbstractShortIterable
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.list.primitive.MutableShortList
collectWithIndex, rejectWithIndex, selectWithIndex, shuffleThis, shuffleThis, sortThisBy, sortThisBy, tap
-
Methods inherited from interface org.eclipse.collections.api.ordered.primitive.OrderedShortIterable
collectWithIndex, rejectWithIndex, selectWithIndex
-
Methods inherited from interface org.eclipse.collections.api.PrimitiveIterable
appendString, appendString, isEmpty, makeString, makeString, makeString, notEmpty, toString
-
Methods inherited from interface org.eclipse.collections.api.ShortIterable
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.ShortList
forEachInBoth
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
DEFAULT_SIZED_EMPTY_ARRAY
private static final short[] DEFAULT_SIZED_EMPTY_ARRAY
-
ZERO_SIZED_ARRAY
private static final short[] 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 short[] items
-
-
Method Detail
-
newListWith
public static ShortArrayList newListWith(short... 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 ShortArrayList newList(ShortIterable source)
-
newWithNValues
public static ShortArrayList newWithNValues(int size, short value)
-
wrapCopy
public static ShortArrayList wrapCopy(short... 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 interfaceMutableShortCollection
-
contains
public boolean contains(short value)
Description copied from interface:ShortIterableReturns true if the value is contained in the ShortIterable, and false if it is not.- Specified by:
containsin interfaceShortIterable
-
newIndexOutOfBoundsException
private java.lang.IndexOutOfBoundsException newIndexOutOfBoundsException(int index)
-
getFirst
public short getFirst()
- Specified by:
getFirstin interfaceOrderedShortIterable
-
getLast
public short getLast()
- Specified by:
getLastin interfaceReversibleShortIterable
-
checkEmpty
private void checkEmpty()
-
indexOf
public int indexOf(short value)
- Specified by:
indexOfin interfaceOrderedShortIterable
-
lastIndexOf
public int lastIndexOf(short value)
- Specified by:
lastIndexOfin interfaceShortList
-
trimToSize
public void trimToSize()
-
transferItemsToNewArrayWithCapacity
private void transferItemsToNewArrayWithCapacity(int newCapacity)
-
copyItemsWithNewCapacity
private short[] copyItemsWithNewCapacity(int newCapacity)
-
sizePlusFiftyPercent
private int sizePlusFiftyPercent(int oldSize)
-
ensureCapacity
public void ensureCapacity(int minCapacity)
-
ensureCapacityForAdd
private void ensureCapacityForAdd()
-
add
public boolean add(short newItem)
- Specified by:
addin interfaceMutableShortCollection
-
addAll
public boolean addAll(short... source)
- Specified by:
addAllin interfaceMutableShortCollection
-
addAll
public boolean addAll(ShortIterable source)
- Specified by:
addAllin interfaceMutableShortCollection
-
copyItems
private void copyItems(int sourceSize, short[] source)
-
throwOutOfBounds
private void throwOutOfBounds(int index)
-
addAtIndex
public void addAtIndex(int index, short element)- Specified by:
addAtIndexin interfaceMutableShortList
-
addAtIndexLessThanSize
private void addAtIndexLessThanSize(int index, short element)
-
addAllAtIndex
public boolean addAllAtIndex(int index, short... source)- Specified by:
addAllAtIndexin interfaceMutableShortList
-
addAllAtIndex
public boolean addAllAtIndex(int index, ShortIterable source)- Specified by:
addAllAtIndexin interfaceMutableShortList
-
shiftElementsAtIndex
private void shiftElementsAtIndex(int index, int sourceSize)
-
remove
public boolean remove(short value)
- Specified by:
removein interfaceMutableShortCollection
-
removeIf
public boolean removeIf(ShortPredicate predicate)
- Specified by:
removeIfin interfaceMutableShortCollection
-
wipeAndResetTheEnd
private void wipeAndResetTheEnd(int newCurrentFilledIndex)
-
removeAll
public boolean removeAll(ShortIterable source)
- Specified by:
removeAllin interfaceMutableShortCollection
-
removeAll
public boolean removeAll(short... source)
- Specified by:
removeAllin interfaceMutableShortCollection
-
retainAll
public boolean retainAll(ShortIterable source)
- Specified by:
retainAllin interfaceMutableShortCollection- See Also:
Collection.retainAll(Collection)
-
retainAll
public boolean retainAll(short... source)
- Specified by:
retainAllin interfaceMutableShortCollection- See Also:
Collection.retainAll(Collection)
-
removeAtIndex
public short removeAtIndex(int index)
- Specified by:
removeAtIndexin interfaceMutableShortList
-
set
public short set(int index, short element)- Specified by:
setin interfaceMutableShortList
-
swap
public void swap(int index1, int index2)- Specified by:
swapin interfaceMutableShortList
-
with
public ShortArrayList with(short element)
- Specified by:
within interfaceMutableShortCollection- Specified by:
within interfaceMutableShortList
-
without
public ShortArrayList without(short element)
- Specified by:
withoutin interfaceMutableShortCollection- Specified by:
withoutin interfaceMutableShortList
-
withAll
public ShortArrayList withAll(ShortIterable elements)
- Specified by:
withAllin interfaceMutableShortCollection- Specified by:
withAllin interfaceMutableShortList
-
withoutAll
public ShortArrayList withoutAll(ShortIterable elements)
- Specified by:
withoutAllin interfaceMutableShortCollection- Specified by:
withoutAllin interfaceMutableShortList
-
with
public ShortArrayList with(short element1, short element2)
-
with
public ShortArrayList with(short element1, short element2, short element3)
-
with
public ShortArrayList with(short element1, short element2, short element3, short... elements)
-
withArrayCopy
private ShortArrayList withArrayCopy(short[] elements, int begin, int length)
-
shortIterator
public MutableShortIterator shortIterator()
Description copied from interface:ShortIterableReturns a primitive iterator that can be used to iterate over the ShortIterable in an imperative style.- Specified by:
shortIteratorin interfaceMutableShortCollection- Specified by:
shortIteratorin interfaceShortIterable
-
each
public void each(ShortProcedure procedure)
Description copied from interface:ShortIterableA synonym for forEach.- Specified by:
eachin interfaceShortIterable- Since:
- 7.0.
-
forEachWithIndex
public void forEachWithIndex(ShortIntProcedure procedure)
- Specified by:
forEachWithIndexin interfaceOrderedShortIterable
-
injectInto
public <T> T injectInto(T injectedValue, ObjectShortToObjectFunction<? super T,? extends T> function)- Specified by:
injectIntoin interfaceShortIterable
-
injectIntoWithIndex
public <T> T injectIntoWithIndex(T injectedValue, ObjectShortIntToObjectFunction<? super T,? extends T> function)- Specified by:
injectIntoWithIndexin interfaceOrderedShortIterable- Specified by:
injectIntoWithIndexin interfaceReversibleShortIterable
-
chunk
public RichIterable<ShortIterable> chunk(int size)
Description copied from interface:ShortIterablePartitions elements in fixed size chunks.- Specified by:
chunkin interfaceShortIterable- Parameters:
size- the number of elements per chunk- Returns:
- A
RichIterablecontainingShortIterables of sizesize, except the last will be truncated if the elements don't divide evenly.
-
count
public int count(ShortPredicate predicate)
Description copied from interface:ShortIterableReturns a count of the number of elements in the ShortIterable that return true for the specified predicate.- Specified by:
countin interfaceShortIterable
-
anySatisfy
public boolean anySatisfy(ShortPredicate predicate)
Description copied from interface:ShortIterableReturns true if any of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.- Specified by:
anySatisfyin interfaceShortIterable
-
allSatisfy
public boolean allSatisfy(ShortPredicate predicate)
Description copied from interface:ShortIterableReturns true if all of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.- Specified by:
allSatisfyin interfaceShortIterable
-
select
public ShortArrayList select(ShortPredicate predicate)
Description copied from interface:ShortIterableReturns a new ShortIterable with all of the elements in the ShortIterable that return true for the specified predicate.- Specified by:
selectin interfaceMutableShortCollection- Specified by:
selectin interfaceMutableShortList- Specified by:
selectin interfaceOrderedShortIterable- Specified by:
selectin interfaceReversibleShortIterable- Specified by:
selectin interfaceShortIterable- Specified by:
selectin interfaceShortList
-
select
public <R extends MutableShortCollection> R select(ShortPredicate predicate, R target)
Description copied from interface:ShortIterableSame asShortIterable.select(ShortPredicate), only the results are added to the target MutableShortCollection.- Specified by:
selectin interfaceShortIterable- Since:
- 8.1.
-
reject
public ShortArrayList reject(ShortPredicate predicate)
Description copied from interface:ShortIterableReturns a new ShortIterable with all of the elements in the ShortIterable that return false for the specified predicate.- Specified by:
rejectin interfaceMutableShortCollection- Specified by:
rejectin interfaceMutableShortList- Specified by:
rejectin interfaceOrderedShortIterable- Specified by:
rejectin interfaceReversibleShortIterable- Specified by:
rejectin interfaceShortIterable- Specified by:
rejectin interfaceShortList
-
reject
public <R extends MutableShortCollection> R reject(ShortPredicate predicate, R target)
Description copied from interface:ShortIterableSame asShortIterable.reject(ShortPredicate), only the results are added to the target MutableShortCollection.- Specified by:
rejectin interfaceShortIterable- Since:
- 8.1.
-
detectIfNone
public short detectIfNone(ShortPredicate predicate, short ifNone)
- Specified by:
detectIfNonein interfaceShortIterable
-
collect
public <V> MutableList<V> collect(ShortToObjectFunction<? extends V> function)
Description copied from interface:ShortIterableReturns 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 interfaceMutableShortCollection- Specified by:
collectin interfaceMutableShortList- Specified by:
collectin interfaceOrderedShortIterable- Specified by:
collectin interfaceReversibleShortIterable- Specified by:
collectin interfaceShortIterable- Specified by:
collectin interfaceShortList
-
collect
public <V,R extends java.util.Collection<V>> R collect(ShortToObjectFunction<? extends V> function, R target)
Description copied from interface:ShortIterableSame asShortIterable.collect(ShortToObjectFunction), only the results are added to the target Collection.- Specified by:
collectin interfaceShortIterable- Since:
- 8.1.
-
max
public short max()
- Specified by:
maxin interfaceShortIterable
-
min
public short min()
- Specified by:
minin interfaceShortIterable
-
sum
public long sum()
- Specified by:
sumin interfaceShortIterable
-
dotProduct
public long dotProduct(ShortList list)
- Specified by:
dotProductin interfaceShortList
-
toArray
public short[] toArray()
Description copied from interface:ShortIterableConverts the ShortIterable to a primitive short array.- Specified by:
toArrayin interfaceShortIterable
-
toArray
public short[] toArray(short[] target)
Description copied from interface:ShortIterableConverts the ShortIterable to a primitive short 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 interfaceShortIterable
-
equals
public boolean equals(java.lang.Object otherList)
Description copied from interface:ShortListFollows the same general contract asList.equals(Object).
-
hashCode
public int hashCode()
Description copied from interface:ShortListFollows 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 MutableShortList asUnmodifiable()
- Specified by:
asUnmodifiablein interfaceMutableShortCollection- Specified by:
asUnmodifiablein interfaceMutableShortList
-
asSynchronized
public MutableShortList asSynchronized()
- Specified by:
asSynchronizedin interfaceMutableShortCollection- Specified by:
asSynchronizedin interfaceMutableShortList
-
toImmutable
public ImmutableShortList toImmutable()
Description copied from interface:MutableShortListReturns an immutable copy of this list.- Specified by:
toImmutablein interfaceMutableShortCollection- Specified by:
toImmutablein interfaceMutableShortList- Specified by:
toImmutablein interfaceShortList
-
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 LazyShortIterable asReversed()
- Specified by:
asReversedin interfaceReversibleShortIterable
-
reverseThis
public ShortArrayList reverseThis()
- Specified by:
reverseThisin interfaceMutableShortList
-
sortThis
public ShortArrayList sortThis()
Description copied from interface:MutableShortListSorts this list mutating its contents and returns the same mutable list (this).- Specified by:
sortThisin interfaceMutableShortList
-
sortThis
public ShortArrayList sortThis(ShortComparator comparator)
Description copied from interface:MutableShortListSorts the internal data structure of this list and returns the list itself as a convenience.- Specified by:
sortThisin interfaceMutableShortList
-
toReversed
public ShortArrayList toReversed()
- Specified by:
toReversedin interfaceMutableShortList- Specified by:
toReversedin interfaceReversibleShortIterable- Specified by:
toReversedin interfaceShortList
-
binarySearch
public int binarySearch(short value)
- Specified by:
binarySearchin interfaceShortList
-
distinct
public MutableShortList distinct()
- Specified by:
distinctin interfaceMutableShortList- Specified by:
distinctin interfaceReversibleShortIterable- Specified by:
distinctin interfaceShortList
-
subList
public MutableShortList subList(int fromIndex, int toIndex)
- Specified by:
subListin interfaceMutableShortList- Specified by:
subListin interfaceShortList- See Also:
List.subList(int fromIndex, int toIndex)
-
zipShort
public MutableList<ShortShortPair> zipShort(ShortIterable iterable)
Description copied from interface:MutableShortListReturns aMutableListformed from thisMutableShortListand anotherShortListby combining corresponding elements in pairs. If one of the twoShortLists is longer than the other, its remaining elements are ignored.- Specified by:
zipShortin interfaceMutableShortList- Specified by:
zipShortin interfaceShortList- Since:
- 9.1.
-
newEmpty
public ShortArrayList newEmpty()
Creates a new empty ShortArrayList.- Specified by:
newEmptyin interfaceMutableShortCollection- Specified by:
newEmptyin interfaceMutableShortList- Since:
- 9.2.
-
zip
public <T> MutableList<ShortObjectPair<T>> zip(java.lang.Iterable<T> iterable)
Description copied from interface:MutableShortListReturns aMutableListformed from thisMutableShortListand 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 interfaceMutableShortList- Specified by:
zipin interfaceShortList- Since:
- 9.1.
-
boxed
public MutableList<java.lang.Short> boxed()
- Specified by:
boxedin interfaceMutableShortList
-
toStack
public MutableShortStack toStack()
Description copied from interface:OrderedShortIterableConverts the collection to a ShortStack.- Specified by:
toStackin interfaceOrderedShortIterable
-
-