Top Description Methods
org.eclipse.collections.api

public Interface ShortIterable

extends PrimitiveIterable
Known Direct Subinterfaces
org.eclipse.collections.api.bag.primitive.ShortBag, org.eclipse.collections.api.collection.primitive.ImmutableShortCollection, org.eclipse.collections.api.collection.primitive.MutableShortCollection, org.eclipse.collections.api.map.primitive.ObjectShortMap, org.eclipse.collections.api.map.primitive.ShortValuesMap, org.eclipse.collections.api.ordered.primitive.OrderedShortIterable, org.eclipse.collections.api.set.primitive.ShortSet, org.eclipse.collections.api.LazyShortIterable
Imports
java.util.Collection, .NoSuchElementException, .IntSummaryStatistics, .Comparator, org.eclipse.collections.api.block.comparator.primitive.ShortComparator, org.eclipse.collections.api.bag.primitive.MutableShortBag, org.eclipse.collections.api.block.function.primitive.ShortToBooleanFunction, .ShortToByteFunction, .ShortToShortFunction, .ShortToCharFunction, .ShortToDoubleFunction, .ShortToFloatFunction, .ShortToIntFunction, .ShortToLongFunction, .ShortToObjectFunction, .BooleanShortToBooleanFunction, .ByteShortToByteFunction, .CharShortToCharFunction, .DoubleShortToDoubleFunction, .FloatShortToFloatFunction, .IntShortToIntFunction, .LongShortToLongFunction, .ObjectShortToObjectFunction, .ShortShortToShortFunction, org.eclipse.collections.api.block.predicate.primitive.ShortPredicate, org.eclipse.collections.api.block.procedure.primitive.ShortProcedure, org.eclipse.collections.api.collection.primitive.MutableBooleanCollection, .MutableByteCollection, .MutableCharCollection, .MutableDoubleCollection, .MutableFloatCollection, .MutableIntCollection, .MutableLongCollection, .MutableShortCollection, org.eclipse.collections.api.iterator.ShortIterator, org.eclipse.collections.api.list.primitive.MutableShortList, org.eclipse.collections.api.set.primitive.ShortSet, .MutableShortSet

ShortIterable is an interface which is memory-optimized for short primitives. It is inspired by the interface RichIterable, and contains a subset of the internal iterator methods on RichIterable like collect, sum, etc. The API also includes an external iterator method, which returns an ShortIterator. ShortIterator helps iterate over the ShortIterable without boxing the primitives. This file was automatically generated from template file primitiveIterable.stg.

Method Summary

Modifier and TypeMethod and Description
public boolean
allSatisfy(ShortPredicate predicate)

Returns true if all of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.

public boolean
anySatisfy(ShortPredicate predicate)

Returns true if any of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.

public LazyShortIterable
asLazy()

Returns a LazyShortIterable adapter wrapping the source ShortIterable.

public double
public default double
averageIfEmpty(double defaultValue)

public default RichIterable<ShortIterable>

Returns:

A RichIterable containing ShortIterables of size size, except the last will be truncated if the elements don't divide evenly.
chunk
(int
the number of elements per chunk
size
)

Partitions elements in fixed size chunks.

public <V> RichIterable<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.

public default <V, R extends Collection<V>> R
collect(ShortToObjectFunction<? extends V> function, R target)

Same as collect(ShortToObjectFunction) , only the results are added to the target Collection.

public default <R extends MutableBooleanCollection> R
collectBoolean(ShortToBooleanFunction function, R target)

Returns the target MutableBooleanCollection with the results of applying the specified function on each element of the source collection.

public default <R extends MutableByteCollection> R
collectByte(ShortToByteFunction function, R target)

Returns the target MutableByteCollection with the results of applying the specified function on each element of the source collection.

public default <R extends MutableCharCollection> R
collectChar(ShortToCharFunction function, R target)

Returns the target MutableCharCollection with the results of applying the specified function on each element of the source collection.

public default <R extends MutableDoubleCollection> R
collectDouble(ShortToDoubleFunction function, R target)

Returns the target MutableDoubleCollection with the results of applying the specified function on each element of the source collection.

public default <R extends MutableFloatCollection> R
collectFloat(ShortToFloatFunction function, R target)

Returns the target MutableFloatCollection with the results of applying the specified function on each element of the source collection.

public default <R extends MutableIntCollection> R
collectInt(ShortToIntFunction function, R target)

Returns the target MutableIntCollection with the results of applying the specified function on each element of the source collection.

public default <R extends MutableLongCollection> R
collectLong(ShortToLongFunction function, R target)

Returns the target MutableLongCollection with the results of applying the specified function on each element of the source collection.

public default <R extends MutableShortCollection> R
collectShort(ShortToShortFunction function, R target)

Returns the target MutableShortCollection with the results of applying the specified function on each element of the source collection.

public boolean
contains(short value)

Returns true if the value is contained in the ShortIterable, and false if it is not.

public default boolean
containsAll(short... source)

Returns true if all of the values specified in the source array are contained in the ShortIterable, and false if they are not.

public default boolean
containsAll(ShortIterable source)

Returns true if all of the values specified in the source ShortIterable are contained in the ShortIterable, and false if they are not.

public default boolean
containsAny(short... source)

Returns true if any of the values specified in the source array are contained in the ShortIterable, and false if they are not.

public default boolean
containsAny(ShortIterable source)

Returns true if any of the values specified in the source ShortIterable are contained in the ShortIterable, and false if they are not.

public default boolean
containsNone(short... source)

Returns true if none of the values specified in the source array are contained in the ShortIterable, and false if they are.

public default boolean
containsNone(ShortIterable source)

Returns true if none of the values specified in the source ShortIterable are contained in the ShortIterable, and false if they are.

public int
count(ShortPredicate predicate)

Returns a count of the number of elements in the ShortIterable that return true for the specified predicate.

public short
detectIfNone(ShortPredicate predicate, short ifNone)

public void
each(ShortProcedure procedure)

A synonym for forEach.

public default <V, R extends Collection<V>> R
flatCollect(ShortToObjectFunction<? extends Iterable<V>> function, R target)

flatCollect is a special case of collect(ShortToObjectFunction).

public default void
forEach(ShortProcedure procedure)

Applies the ShortProcedure to each element in the ShortIterable.

public <T> T
injectInto(T injectedValue, ObjectShortToObjectFunction<? super T, ? extends T> function)

public default boolean
injectIntoBoolean(boolean injectedValue, BooleanShortToBooleanFunction function)

Returns the final boolean result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public default byte
injectIntoByte(byte injectedValue, ByteShortToByteFunction function)

Returns the final byte result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public default char
injectIntoChar(char injectedValue, CharShortToCharFunction function)

Returns the final char result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public default double
injectIntoDouble(double injectedValue, DoubleShortToDoubleFunction function)

Returns the final double result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public default float
injectIntoFloat(float injectedValue, FloatShortToFloatFunction function)

Returns the final float result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public default int
injectIntoInt(int injectedValue, IntShortToIntFunction function)

Returns the final int result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public default long
injectIntoLong(long injectedValue, LongShortToLongFunction function)

Returns the final long result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public default short
injectIntoShort(short injectedValue, ShortShortToShortFunction function)

Returns the final short result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public short
max()

public short
maxIfEmpty(short defaultValue)

public double
public default double
medianIfEmpty(double defaultValue)

public short
min()

public short
minIfEmpty(short defaultValue)

public default boolean
noneSatisfy(ShortPredicate predicate)

Returns true if none of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.

public default long
public default long
reduceIfEmpty(LongShortToLongFunction accumulator, long defaultValue)

public ShortIterable
reject(ShortPredicate predicate)

Returns a new ShortIterable with all of the elements in the ShortIterable that return false for the specified predicate.

public default <R extends MutableShortCollection> R
reject(ShortPredicate predicate, R target)

Same as reject(ShortPredicate) , only the results are added to the target MutableShortCollection.

public ShortIterable
select(ShortPredicate predicate)

Returns a new ShortIterable with all of the elements in the ShortIterable that return true for the specified predicate.

public default <R extends MutableShortCollection> R
select(ShortPredicate predicate, R target)

Same as select(ShortPredicate) , only the results are added to the target MutableShortCollection.

public ShortIterator
shortIterator()

Returns a primitive iterator that can be used to iterate over the ShortIterable in an imperative style.

public long
sum()

public default IntSummaryStatistics
public default ShortIterable
tap(ShortProcedure procedure)

public short[]
toArray()

Converts the ShortIterable to a primitive short array.

public default short[]
toArray(short[] target)

Converts the ShortIterable to a primitive short array.

public MutableShortBag
toBag()

Converts the ShortIterable to a new MutableShortBag.

public MutableShortList
toList()

Converts the ShortIterable to a new MutableShortList.

public MutableShortSet
toSet()

Converts the ShortIterable to a new MutableShortSet.

public short[]
public MutableShortList
public default MutableShortList
toSortedList(ShortComparator comparator)

Converts the collection to a MutableShortList implementation sorted using the provided comparator.

public default <T> MutableShortList
toSortedListBy(ShortToObjectFunction<T> function)

Converts the collection to a MutableShortListImplementation sorted based on the natural order of the key returned by function.

public default <T> MutableShortList
toSortedListBy(ShortToObjectFunction<T> function, Comparator<? super T> comparator)

Converts the collection to a MutableShortList implementation, which is sorted based on the key returned by function using the provided comparator.

Inherited from org.eclipse.collections.api.PrimitiveIterable:
appendStringappendStringappendStringisEmptymakeStringmakeStringmakeStringnotEmptysizetoString

Method Detail

allSatisfyback to summary
public boolean allSatisfy(ShortPredicate predicate)

Returns true if all of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.

anySatisfyback to summary
public boolean anySatisfy(ShortPredicate predicate)

Returns true if any of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.

asLazyback to summary
public LazyShortIterable asLazy()

Returns a LazyShortIterable adapter wrapping the source ShortIterable.

averageback to summary
public double average()
averageIfEmptyback to summary
public default double averageIfEmpty(double defaultValue)
Since
9.0
chunkback to summary
public default RichIterable<ShortIterable> chunk(int size)

Partitions elements in fixed size chunks.

Parameters
size:int

the number of elements per chunk

Returns:RichIterable<ShortIterable>

A RichIterable containing ShortIterables of size size, except the last will be truncated if the elements don't divide evenly.

Since
9.2
collectback to summary
public <V> RichIterable<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. This method is also commonly called transform or map.

collectback to summary
public default <V, R extends Collection<V>> R collect(ShortToObjectFunction<? extends V> function, R target)

Same as collect(ShortToObjectFunction) , only the results are added to the target Collection.

Since
8.1.
collectBooleanback to summary
public default <R extends MutableBooleanCollection> R collectBoolean(ShortToBooleanFunction function, R target)

Returns the target MutableBooleanCollection with the results of applying the specified function on each element of the source collection.

Since
8.1.
collectByteback to summary
public default <R extends MutableByteCollection> R collectByte(ShortToByteFunction function, R target)

Returns the target MutableByteCollection with the results of applying the specified function on each element of the source collection.

Since
8.1.
collectCharback to summary
public default <R extends MutableCharCollection> R collectChar(ShortToCharFunction function, R target)

Returns the target MutableCharCollection with the results of applying the specified function on each element of the source collection.

Since
8.1.
collectDoubleback to summary
public default <R extends MutableDoubleCollection> R collectDouble(ShortToDoubleFunction function, R target)

Returns the target MutableDoubleCollection with the results of applying the specified function on each element of the source collection.

Since
8.1.
collectFloatback to summary
public default <R extends MutableFloatCollection> R collectFloat(ShortToFloatFunction function, R target)

Returns the target MutableFloatCollection with the results of applying the specified function on each element of the source collection.

Since
8.1.
collectIntback to summary
public default <R extends MutableIntCollection> R collectInt(ShortToIntFunction function, R target)

Returns the target MutableIntCollection with the results of applying the specified function on each element of the source collection.

Since
8.1.
collectLongback to summary
public default <R extends MutableLongCollection> R collectLong(ShortToLongFunction function, R target)

Returns the target MutableLongCollection with the results of applying the specified function on each element of the source collection.

Since
8.1.
collectShortback to summary
public default <R extends MutableShortCollection> R collectShort(ShortToShortFunction function, R target)

Returns the target MutableShortCollection with the results of applying the specified function on each element of the source collection.

Since
8.1.
containsback to summary
public boolean contains(short value)

Returns true if the value is contained in the ShortIterable, and false if it is not.

containsAllback to summary
public default boolean containsAll(short... source)

Returns true if all of the values specified in the source array are contained in the ShortIterable, and false if they are not.

containsAllback to summary
public default boolean containsAll(ShortIterable source)

Returns true if all of the values specified in the source ShortIterable are contained in the ShortIterable, and false if they are not.

containsAnyback to summary
public default boolean containsAny(short... source)

Returns true if any of the values specified in the source array are contained in the ShortIterable, and false if they are not.

Since
11.0
containsAnyback to summary
public default boolean containsAny(ShortIterable source)

Returns true if any of the values specified in the source ShortIterable are contained in the ShortIterable, and false if they are not.

Since
11.0
containsNoneback to summary
public default boolean containsNone(short... source)

Returns true if none of the values specified in the source array are contained in the ShortIterable, and false if they are.

Since
11.0
containsNoneback to summary
public default boolean containsNone(ShortIterable source)

Returns true if none of the values specified in the source ShortIterable are contained in the ShortIterable, and false if they are.

Since
11.0
countback to summary
public int count(ShortPredicate predicate)

Returns a count of the number of elements in the ShortIterable that return true for the specified predicate.

detectIfNoneback to summary
public short detectIfNone(ShortPredicate predicate, short ifNone)
eachback to summary
public void each(ShortProcedure procedure)

A synonym for forEach.

Since
7.0.
flatCollectback to summary
public default <V, R extends Collection<V>> R flatCollect(ShortToObjectFunction<? extends Iterable<V>> function, R target)

flatCollect is a special case of collect(ShortToObjectFunction). With collect, when the ShortToObjectFunction returns a collection, the result is a collection of collections. flatCollect outputs a single "flattened" collection instead. This method is commonly called flatMap.

Since
8.1.
forEachback to summary
public default void forEach(ShortProcedure procedure)

Applies the ShortProcedure to each element in the ShortIterable.

injectIntoback to summary
public <T> T injectInto(T injectedValue, ObjectShortToObjectFunction<? super T, ? extends T> function)
injectIntoBooleanback to summary
public default boolean injectIntoBoolean(boolean injectedValue, BooleanShortToBooleanFunction function)

Returns the final boolean result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.

Since
11.1
injectIntoByteback to summary
public default byte injectIntoByte(byte injectedValue, ByteShortToByteFunction function)

Returns the final byte result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.

Since
11.1
injectIntoCharback to summary
public default char injectIntoChar(char injectedValue, CharShortToCharFunction function)

Returns the final char result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.

Since
11.1
injectIntoDoubleback to summary
public default double injectIntoDouble(double injectedValue, DoubleShortToDoubleFunction function)

Returns the final double result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.

Since
11.1
injectIntoFloatback to summary
public default float injectIntoFloat(float injectedValue, FloatShortToFloatFunction function)

Returns the final float result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.

Since
11.1
injectIntoIntback to summary
public default int injectIntoInt(int injectedValue, IntShortToIntFunction function)

Returns the final int result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.

Since
11.1
injectIntoLongback to summary
public default long injectIntoLong(long injectedValue, LongShortToLongFunction function)

Returns the final long result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.

Since
11.1
injectIntoShortback to summary
public default short injectIntoShort(short injectedValue, ShortShortToShortFunction function)

Returns the final short result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.

Since
11.1
maxback to summary
public short max()
maxIfEmptyback to summary
public short maxIfEmpty(short defaultValue)
medianback to summary
public double median()
medianIfEmptyback to summary
public default double medianIfEmpty(double defaultValue)
Since
9.0
minback to summary
public short min()
minIfEmptyback to summary
public short minIfEmpty(short defaultValue)
noneSatisfyback to summary
public default boolean noneSatisfy(ShortPredicate predicate)

Returns true if none of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.

reduceback to summary
public default long reduce(LongShortToLongFunction accumulator)
Since
10.0
See Also
RichIterable#reduce(BinaryOperator)
reduceIfEmptyback to summary
public default long reduceIfEmpty(LongShortToLongFunction accumulator, long defaultValue)
Since
10.0
See Also
reduce(LongShortToLongFunction)
rejectback to summary
public ShortIterable reject(ShortPredicate predicate)

Returns a new ShortIterable with all of the elements in the ShortIterable that return false for the specified predicate.

rejectback to summary
public default <R extends MutableShortCollection> R reject(ShortPredicate predicate, R target)

Same as reject(ShortPredicate) , only the results are added to the target MutableShortCollection.

Since
8.1.
selectback to summary
public ShortIterable select(ShortPredicate predicate)

Returns a new ShortIterable with all of the elements in the ShortIterable that return true for the specified predicate.

selectback to summary
public default <R extends MutableShortCollection> R select(ShortPredicate predicate, R target)

Same as select(ShortPredicate) , only the results are added to the target MutableShortCollection.

Since
8.1.
shortIteratorback to summary
public ShortIterator shortIterator()

Returns a primitive iterator that can be used to iterate over the ShortIterable in an imperative style.

sumback to summary
public long sum()
summaryStatisticsback to summary
public default IntSummaryStatistics summaryStatistics()
Since
8.0
tapback to summary
public default ShortIterable tap(ShortProcedure procedure)
Since
9.0.
toArrayback to summary
public short[] toArray()

Converts the ShortIterable to a primitive short array.

toArrayback to summary
public default short[] toArray(short[] target)

Converts 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.

toBagback to summary
public MutableShortBag toBag()

Converts the ShortIterable to a new MutableShortBag.

toListback to summary
public MutableShortList toList()

Converts the ShortIterable to a new MutableShortList.

toSetback to summary
public MutableShortSet toSet()

Converts the ShortIterable to a new MutableShortSet.

toSortedArrayback to summary
public short[] toSortedArray()
toSortedListback to summary
public MutableShortList toSortedList()
toSortedListback to summary
public default MutableShortList toSortedList(ShortComparator comparator)

Converts the collection to a MutableShortList implementation sorted using the provided comparator.

toSortedListByback to summary
public default <T> MutableShortList toSortedListBy(ShortToObjectFunction<T> function)

Converts the collection to a MutableShortListImplementation sorted based on the natural order of the key returned by function.

toSortedListByback to summary
public default <T> MutableShortList toSortedListBy(ShortToObjectFunction<T> function, Comparator<? super T> comparator)

Converts the collection to a MutableShortList implementation, which is sorted based on the key returned by function using the provided comparator.