Class ShortArrayList
java.lang.Object
org.eclipse.collections.impl.primitive.AbstractShortIterable
org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList
- All Implemented Interfaces:
Externalizable, Serializable, MutableShortCollection, MutableShortList, ShortList, OrderedShortIterable, ReversibleShortIterable, PrimitiveIterable, ShortIterable
public class ShortArrayList
extends AbstractShortIterable
implements MutableShortList, 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:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final short[]protected short[]private static final intprivate static final longprotected intprivate static final short[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(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(Appendable appendable, String start, String separator, String end) Prints a string representation of this collection onto the givenAppendable.intbinarySearch(short value) boxed()private voidchunk(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 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) distinct()longdotProduct(ShortList list) voideach(ShortProcedure procedure) A synonym for forEach.voidensureCapacity(int minCapacity) private voidbooleanFollows 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()newEmpty()Creates a new empty ShortArrayList.private 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) voidreject(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) select(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) 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) sortThis()Sorts this list mutating its contents and returns the same mutable list (this).sortThis(ShortComparator 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) short[]toArray()Converts the ShortIterable to a primitive short array.short[]toArray(short[] target) Converts the ShortIterable to a primitive short array.Returns an immutable copy of this list.toStack()Converts the collection to a ShortStack.private voidtransferItemsToNewArrayWithCapacity(int newCapacity) voidprivate voidwipeAndResetTheEnd(int newCurrentFilledIndex) with(short element) with(short element1, short element2) with(short element1, short element2, short element3) with(short element1, short element2, short element3, short... elements) withAll(ShortIterable elements) private ShortArrayListwithArrayCopy(short[] elements, int begin, int length) without(short element) withoutAll(ShortIterable elements) static ShortArrayListwrapCopy(short... array) Creates a new list by first copying the array passed in.void<T> MutableList<ShortObjectPair<T>> Returns aMutableListformed from thisMutableShortListand aListIterableby combining corresponding elements in pairs.zipShort(ShortIterable iterable) Returns aMutableListformed from thisMutableShortListand anotherShortListby combining corresponding elements in pairs.Methods inherited from class AbstractShortIterable
asLazy, average, maxIfEmpty, median, minIfEmpty, toBag, toList, toSet, toSortedArray, toSortedList, toStringMethods inherited from interface MutableShortList
collectWithIndex, rejectWithIndex, selectWithIndex, shuffleThis, shuffleThis, sortThisBy, sortThisBy, tapMethods inherited from interface OrderedShortIterable
collectWithIndex, rejectWithIndex, selectWithIndexMethods inherited from interface PrimitiveIterable
appendString, appendString, isEmpty, makeString, makeString, makeString, notEmpty, toStringMethods inherited from interface 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, toSortedListByMethods inherited from interface ShortList
forEachInBoth
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
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:
-
size
protected int size -
items
protected transient short[] items
-
-
Constructor Details
-
ShortArrayList
public ShortArrayList() -
ShortArrayList
public ShortArrayList(int initialCapacity) -
ShortArrayList
public ShortArrayList(short... 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 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
-
get
-
newIndexOutOfBoundsException
-
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
- 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
- Specified by:
addAllAtIndexin interfaceMutableShortList
-
shiftElementsAtIndex
private void shiftElementsAtIndex(int index, int sourceSize) -
remove
public boolean remove(short value) - Specified by:
removein interfaceMutableShortCollection
-
removeIf
- Specified by:
removeIfin interfaceMutableShortCollection
-
wipeAndResetTheEnd
private void wipeAndResetTheEnd(int newCurrentFilledIndex) -
removeAll
- Specified by:
removeAllin interfaceMutableShortCollection
-
removeAll
public boolean removeAll(short... source) - Specified by:
removeAllin interfaceMutableShortCollection
-
retainAll
- Specified by:
retainAllin interfaceMutableShortCollection- See Also:
-
retainAll
public boolean retainAll(short... source) - Specified by:
retainAllin interfaceMutableShortCollection- See Also:
-
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
- Specified by:
within interfaceMutableShortCollection- Specified by:
within interfaceMutableShortList
-
without
- Specified by:
withoutin interfaceMutableShortCollection- Specified by:
withoutin interfaceMutableShortList
-
withAll
- Specified by:
withAllin interfaceMutableShortCollection- Specified by:
withAllin interfaceMutableShortList
-
withoutAll
- Specified by:
withoutAllin interfaceMutableShortCollection- Specified by:
withoutAllin interfaceMutableShortList
-
with
-
with
-
with
-
withArrayCopy
-
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
Description copied from interface:ShortIterableA synonym for forEach.- Specified by:
eachin interfaceShortIterable- Since:
- 7.0.
-
forEachWithIndex
- 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
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
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
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
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
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
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
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
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
- Specified by:
detectIfNonein interfaceShortIterable
-
collect
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 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
- 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
-
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 interfaceMutableShortCollection- Specified by:
asUnmodifiablein interfaceMutableShortList
-
asSynchronized
- Specified by:
asSynchronizedin interfaceMutableShortCollection- Specified by:
asSynchronizedin interfaceMutableShortList
-
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
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOException
-
asReversed
- Specified by:
asReversedin interfaceReversibleShortIterable
-
reverseThis
- Specified by:
reverseThisin interfaceMutableShortList
-
sortThis
Description copied from interface:MutableShortListSorts this list mutating its contents and returns the same mutable list (this).- Specified by:
sortThisin interfaceMutableShortList
-
sortThis
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
- Specified by:
toReversedin interfaceMutableShortList- Specified by:
toReversedin interfaceReversibleShortIterable- Specified by:
toReversedin interfaceShortList
-
binarySearch
public int binarySearch(short value) - Specified by:
binarySearchin interfaceShortList
-
distinct
- Specified by:
distinctin interfaceMutableShortList- Specified by:
distinctin interfaceReversibleShortIterable- Specified by:
distinctin interfaceShortList
-
subList
- Specified by:
subListin interfaceMutableShortList- Specified by:
subListin interfaceShortList- See Also:
-
zipShort
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
Creates a new empty ShortArrayList.- Specified by:
newEmptyin interfaceMutableShortCollection- Specified by:
newEmptyin interfaceMutableShortList- Since:
- 9.2.
-
zip
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
- Specified by:
boxedin interfaceMutableShortList
-
toStack
Description copied from interface:OrderedShortIterableConverts the collection to a ShortStack.- Specified by:
toStackin interfaceOrderedShortIterable
-