Package org.eclipse.collections.api
Interface ShortIterable
-
- All Superinterfaces:
PrimitiveIterable
- All Known Subinterfaces:
ByteShortMap,CharShortMap,DoubleShortMap,FloatShortMap,ImmutableByteShortMap,ImmutableCharShortMap,ImmutableDoubleShortMap,ImmutableFloatShortMap,ImmutableIntShortMap,ImmutableLongShortMap,ImmutableObjectShortMap<K>,ImmutableShortBag,ImmutableShortCollection,ImmutableShortList,ImmutableShortSet,ImmutableShortShortMap,ImmutableShortStack,IntShortMap,LazyShortIterable,LongShortMap,MutableByteShortMap,MutableCharShortMap,MutableDoubleShortMap,MutableFloatShortMap,MutableIntShortMap,MutableLongShortMap,MutableObjectShortMap<K>,MutableShortBag,MutableShortCollection,MutableShortList,MutableShortSet,MutableShortShortMap,MutableShortStack,MutableShortValuesMap,ObjectShortMap<K>,OrderedShortIterable,ReversibleShortIterable,ShortBag,ShortList,ShortSet,ShortShortMap,ShortStack,ShortValuesMap
public interface ShortIterable extends PrimitiveIterable
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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description 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.LazyShortIterableasLazy()Returns a LazyShortIterable adapter wrapping the source ShortIterable.doubleaverage()default doubleaverageIfEmpty(double defaultValue)default RichIterable<ShortIterable>chunk(int size)Partitions elements in fixed size chunks.<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.default <V,R extends Collection<V>>
Rcollect(ShortToObjectFunction<? extends V> function, R target)Same ascollect(ShortToObjectFunction), only the results are added to the target Collection.default <R extends MutableBooleanCollection>
RcollectBoolean(ShortToBooleanFunction function, R target)Returns the targetMutableBooleanCollectionwith the results of applying the specified function on each element of the source collection.default <R extends MutableByteCollection>
RcollectByte(ShortToByteFunction function, R target)Returns the targetMutableByteCollectionwith the results of applying the specified function on each element of the source collection.default <R extends MutableCharCollection>
RcollectChar(ShortToCharFunction function, R target)Returns the targetMutableCharCollectionwith the results of applying the specified function on each element of the source collection.default <R extends MutableDoubleCollection>
RcollectDouble(ShortToDoubleFunction function, R target)Returns the targetMutableDoubleCollectionwith the results of applying the specified function on each element of the source collection.default <R extends MutableFloatCollection>
RcollectFloat(ShortToFloatFunction function, R target)Returns the targetMutableFloatCollectionwith the results of applying the specified function on each element of the source collection.default <R extends MutableIntCollection>
RcollectInt(ShortToIntFunction function, R target)Returns the targetMutableIntCollectionwith the results of applying the specified function on each element of the source collection.default <R extends MutableLongCollection>
RcollectLong(ShortToLongFunction function, R target)Returns the targetMutableLongCollectionwith the results of applying the specified function on each element of the source collection.default <R extends MutableShortCollection>
RcollectShort(ShortToShortFunction function, R target)Returns the targetMutableShortCollectionwith the results of applying the specified function on each element of the source collection.booleancontains(short value)Returns true if the value is contained in the ShortIterable, and false if it is not.default booleancontainsAll(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.default booleancontainsAll(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.default booleancontainsAny(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.default booleancontainsAny(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.default booleancontainsNone(short... source)Returns true if none of the values specified in the source array are contained in the ShortIterable, and false if they are.default booleancontainsNone(ShortIterable source)Returns true if none of the values specified in the source ShortIterable are contained in the ShortIterable, and false if they are.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)voideach(ShortProcedure procedure)A synonym for forEach.default <V,R extends Collection<V>>
RflatCollect(ShortToObjectFunction<? extends Iterable<V>> function, R target)flatCollectis a special case ofcollect(ShortToObjectFunction).default voidforEach(ShortProcedure procedure)Applies the ShortProcedure to each element in the ShortIterable.<T> TinjectInto(T injectedValue, ObjectShortToObjectFunction<? super T,? extends T> function)default booleaninjectIntoBoolean(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.default byteinjectIntoByte(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.default charinjectIntoChar(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.default doubleinjectIntoDouble(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.default floatinjectIntoFloat(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.default intinjectIntoInt(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.default longinjectIntoLong(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.default shortinjectIntoShort(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.shortmax()shortmaxIfEmpty(short defaultValue)doublemedian()default doublemedianIfEmpty(double defaultValue)shortmin()shortminIfEmpty(short defaultValue)default booleannoneSatisfy(ShortPredicate predicate)Returns true if none of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.default longreduce(LongShortToLongFunction accumulator)default longreduceIfEmpty(LongShortToLongFunction accumulator, long defaultValue)ShortIterablereject(ShortPredicate predicate)Returns a new ShortIterable with all of the elements in the ShortIterable that return false for the specified predicate.default <R extends MutableShortCollection>
Rreject(ShortPredicate predicate, R target)Same asreject(ShortPredicate), only the results are added to the target MutableShortCollection.ShortIterableselect(ShortPredicate predicate)Returns a new ShortIterable with all of the elements in the ShortIterable that return true for the specified predicate.default <R extends MutableShortCollection>
Rselect(ShortPredicate predicate, R target)Same asselect(ShortPredicate), only the results are added to the target MutableShortCollection.ShortIteratorshortIterator()Returns a primitive iterator that can be used to iterate over the ShortIterable in an imperative style.longsum()default IntSummaryStatisticssummaryStatistics()default ShortIterabletap(ShortProcedure procedure)short[]toArray()Converts the ShortIterable to a primitive short array.default short[]toArray(short[] target)Converts the ShortIterable to a primitive short array.MutableShortBagtoBag()Converts the ShortIterable to a new MutableShortBag.MutableShortListtoList()Converts the ShortIterable to a new MutableShortList.MutableShortSettoSet()Converts the ShortIterable to a new MutableShortSet.short[]toSortedArray()MutableShortListtoSortedList()default MutableShortListtoSortedList(ShortComparator comparator)Converts the collection to a MutableShortList implementation sorted using the provided comparator.default <T> MutableShortListtoSortedListBy(ShortToObjectFunction<T> function)Converts the collection to a MutableShortListImplementation sorted based on the natural order of the key returned byfunction.default <T> MutableShortListtoSortedListBy(ShortToObjectFunction<T> function, Comparator<? super T> comparator)Converts the collection to a MutableShortList implementation, which is sorted based on the key returned byfunctionusing the providedcomparator.-
Methods inherited from interface org.eclipse.collections.api.PrimitiveIterable
appendString, appendString, appendString, isEmpty, makeString, makeString, makeString, notEmpty, size, toString
-
-
-
-
Method Detail
-
shortIterator
ShortIterator shortIterator()
Returns a primitive iterator that can be used to iterate over the ShortIterable in an imperative style.
-
toArray
short[] toArray()
Converts the ShortIterable to a primitive short array.
-
toArray
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.
-
contains
boolean contains(short value)
Returns true if the value is contained in the ShortIterable, and false if it is not.
-
containsAll
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.
-
containsAll
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.
-
containsAny
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
-
containsAny
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
-
containsNone
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
-
containsNone
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
-
forEach
default void forEach(ShortProcedure procedure)
Applies the ShortProcedure to each element in the ShortIterable.
-
each
void each(ShortProcedure procedure)
A synonym for forEach.- Since:
- 7.0.
-
tap
default ShortIterable tap(ShortProcedure procedure)
- Since:
- 9.0.
-
select
ShortIterable select(ShortPredicate predicate)
Returns a new ShortIterable with all of the elements in the ShortIterable that return true for the specified predicate.
-
reject
ShortIterable reject(ShortPredicate predicate)
Returns a new ShortIterable with all of the elements in the ShortIterable that return false for the specified predicate.
-
select
default <R extends MutableShortCollection> R select(ShortPredicate predicate, R target)
Same asselect(ShortPredicate), only the results are added to the target MutableShortCollection.- Since:
- 8.1.
-
reject
default <R extends MutableShortCollection> R reject(ShortPredicate predicate, R target)
Same asreject(ShortPredicate), only the results are added to the target MutableShortCollection.- Since:
- 8.1.
-
collect
<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.
-
collect
default <V,R extends Collection<V>> R collect(ShortToObjectFunction<? extends V> function, R target)
Same ascollect(ShortToObjectFunction), only the results are added to the target Collection.- Since:
- 8.1.
-
flatCollect
default <V,R extends Collection<V>> R flatCollect(ShortToObjectFunction<? extends Iterable<V>> function, R target)
flatCollectis a special case ofcollect(ShortToObjectFunction). Withcollect, when theShortToObjectFunctionreturns a collection, the result is a collection of collections.flatCollectoutputs a single "flattened" collection instead. This method is commonly called flatMap.- Since:
- 8.1.
-
collectBoolean
default <R extends MutableBooleanCollection> R collectBoolean(ShortToBooleanFunction function, R target)
Returns the targetMutableBooleanCollectionwith the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
collectByte
default <R extends MutableByteCollection> R collectByte(ShortToByteFunction function, R target)
Returns the targetMutableByteCollectionwith the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
collectChar
default <R extends MutableCharCollection> R collectChar(ShortToCharFunction function, R target)
Returns the targetMutableCharCollectionwith the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
collectShort
default <R extends MutableShortCollection> R collectShort(ShortToShortFunction function, R target)
Returns the targetMutableShortCollectionwith the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
collectInt
default <R extends MutableIntCollection> R collectInt(ShortToIntFunction function, R target)
Returns the targetMutableIntCollectionwith the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
collectFloat
default <R extends MutableFloatCollection> R collectFloat(ShortToFloatFunction function, R target)
Returns the targetMutableFloatCollectionwith the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
collectLong
default <R extends MutableLongCollection> R collectLong(ShortToLongFunction function, R target)
Returns the targetMutableLongCollectionwith the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
collectDouble
default <R extends MutableDoubleCollection> R collectDouble(ShortToDoubleFunction function, R target)
Returns the targetMutableDoubleCollectionwith the results of applying the specified function on each element of the source collection.- Since:
- 8.1.
-
detectIfNone
short detectIfNone(ShortPredicate predicate, short ifNone)
-
count
int count(ShortPredicate predicate)
Returns a count of the number of elements in the ShortIterable that return true for the specified predicate.
-
anySatisfy
boolean anySatisfy(ShortPredicate predicate)
Returns true if any of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.
-
allSatisfy
boolean allSatisfy(ShortPredicate predicate)
Returns true if all of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.
-
noneSatisfy
default boolean noneSatisfy(ShortPredicate predicate)
Returns true if none of the elements in the ShortIterable return true for the specified predicate, otherwise returns false.
-
toList
MutableShortList toList()
Converts the ShortIterable to a new MutableShortList.
-
toSet
MutableShortSet toSet()
Converts the ShortIterable to a new MutableShortSet.
-
toBag
MutableShortBag toBag()
Converts the ShortIterable to a new MutableShortBag.
-
asLazy
LazyShortIterable asLazy()
Returns a LazyShortIterable adapter wrapping the source ShortIterable.
-
injectInto
<T> T injectInto(T injectedValue, ObjectShortToObjectFunction<? super T,? extends T> function)
-
injectIntoBoolean
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
-
injectIntoByte
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
-
injectIntoChar
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
-
injectIntoShort
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
-
injectIntoInt
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
-
injectIntoFloat
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
-
injectIntoLong
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
-
injectIntoDouble
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
-
reduceIfEmpty
default long reduceIfEmpty(LongShortToLongFunction accumulator, long defaultValue)
- Since:
- 10.0
- See Also:
reduce(LongShortToLongFunction)
-
reduce
default long reduce(LongShortToLongFunction accumulator)
- Since:
- 10.0
- See Also:
RichIterable.reduce(BinaryOperator)
-
chunk
default RichIterable<ShortIterable> chunk(int size)
Partitions elements in fixed size chunks.- 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. - Since:
- 9.2
-
sum
long sum()
-
summaryStatistics
default IntSummaryStatistics summaryStatistics()
- Since:
- 8.0
-
max
short max()
-
maxIfEmpty
short maxIfEmpty(short defaultValue)
-
min
short min()
-
minIfEmpty
short minIfEmpty(short defaultValue)
-
average
double average()
-
averageIfEmpty
default double averageIfEmpty(double defaultValue)
- Since:
- 9.0
-
median
double median()
-
medianIfEmpty
default double medianIfEmpty(double defaultValue)
- Since:
- 9.0
-
toSortedArray
short[] toSortedArray()
-
toSortedList
MutableShortList toSortedList()
-
toSortedList
default MutableShortList toSortedList(ShortComparator comparator)
Converts the collection to a MutableShortList implementation sorted using the provided comparator.
-
toSortedListBy
default <T> MutableShortList toSortedListBy(ShortToObjectFunction<T> function)
Converts the collection to a MutableShortListImplementation sorted based on the natural order of the key returned byfunction.
-
toSortedListBy
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 byfunctionusing the providedcomparator.
-
-