接口 FastStream<T>
- 所有超级接口:
Iterable<T>
- 所有已知实现类:
FastStream.Concatenated,FastStream.ConcatenatedN,FastStream.Distinct,FastStream.Filtered,FastStream.FlatMapped,FastStream.Group,FastStream.Grouped,FastStream.Mapped,FastStream.OfN,FastStream.OfSingle,FastStream.Peeked,FastStream.Reversed,FastStream.Sliced,FastStream.Sorted,FastStream.Wrapped,FastStream.WrappedSpl
-
嵌套类概要
嵌套类修饰符和类型接口说明static final classstatic final classAFastStreamfor an array of concatenatedIterables.static final classstatic final classAFastStreamwith a filtering function applied.static final classAFastStreamwith a flat mapping option applied to each element flattened together.static final classRepresents a Key to sequence of values in agroupBy(java.util.function.Function<? super T, ? extends K>)grouping.static final classAFastStreamof elements grouped by a specific key.static classstatic final classAFastStreamwith a mapping function applied.static final classAFastStreamfor an array of elements.static final classAFastStreamfor a single element.static final classAFastStreamwith a listener attached.static final classAFastStreamin reverse order.static final classAFastStreamwith a min/max filter applied.static final classAFastStreamsorted by a comparator.static final classstatic final classWraps a regularIterableinto aFastStream.static final classWraps aSpliteratorinto aFastStream -
字段概要
字段 -
方法概要
修饰符和类型方法说明default booleanTests if all elements in theFastStreammatch the providedPredicate.default booleanTests if any element in theFastStreammatches the providedPredicate.default FastStream<T>Returns aFastStreamwith the providedIterableconcatenated after.static <T> FastStream<T>Returns a concatenatedFastStreamcontaining the elements from the providedIterablearray.static <T> FastStream<T>concatMany(Iterable<? extends Iterable<? extends T>> iterables) default intcount()Evaluates the stream, counting the number of elements contained within.default FastStream<T>distinct()Returns aFastStreamcontaining all elements that are unique according to theirObject.hashCode()/Object.equals(java.lang.Object)identity.default doubledoubleSum(ToDoubleFunction<? super T> func) Sum all elements in the stream to a double, using the providedToDoubleFunctionto convert each element to a double.static <T> FastStream<T>empty()Returns an emptyFastStreamsingleton.default FastStream<T>Returns aFastStreamcontaining all elements that pass the providedPredicatefilter.default FastStream<T>Returns aFastStreamcontaining all elements that fail the providedPredicatefilter.findLast()default Tfirst()default Tdefault TfirstOrDefault(T _default) default <R> FastStream<R>Returns aFastStreamwith each element transformed by the providedFunctionconcatenated together.fold(BinaryOperator<T> accumulator) Returns the result of a folding operation applied to theFastStreamcontents.default <U> Ufold(U identity, BiFunction<? super @Nullable U, ? super T, ? extends U> accumulator) Returns the result of a folding operation applied to theFastStreamcontents.default <K> FastStream<FastStream.Group<K,T>> Returns aFastStreamcontaining all elements grouped by a key.default <K,V> FastStream<FastStream.Group<K, V>> Returns aFastStreamcontaining all elements grouped by a key.static <T> FastStream.TypeCheck<T,T> infer()Used to nudge Javac to perform looser inference on return types of some collecting functions provided in here.default intintSum(ToIntFunction<? super T> func) Sum all elements in the stream to an integer, using the providedToIntFunctionto convert each element to an integer.default booleanisEmpty()Tests if the stream is empty.default StringJoin all elements of this stream together into aString, separated bysep.default intReturns the known length for the stream.default intknownLength(boolean consumeToCalculate) Returns the known length for the stream.default Tlast()default Tdefault TlastOrDefault(T _default) default FastStream<T>limit(@org.jetbrains.annotations.Range(from=-1L, to=2147483647L) int max) Returns aFastStreamwhich will let at mostmaxelements pass.default longlongSum(ToLongFunction<? super T> func) Sum all elements in the stream to a long, using the providedToLongFunctionto convert each element to a long.default <R> FastStream<R>Returns aFastStreamwith each element transformed by the providedFunction.default TmaxBy(ToIntFunction<T> func) Returns the element in the stream with the highest value returned by the providedToIntFunction.default TmaxByOrDefault(ToIntFunction<T> func) Returns the element in the stream with the highest value returned by the providedToIntFunction.default TmaxByOrDefault(ToIntFunction<T> func, T _default) Returns the element in the stream with the highest value returned by the providedToIntFunction.default booleanTests if no elements in theFastStreammatch the providedPredicate.static <T> FastStream<T>of()Overload ofempty()for convenience.static <T> FastStream<T>Wraps the providedIterableto aFastStreamstatic <T> FastStream<T>Returns aFastStreamfor anOptional.static <T> FastStream<T>of(Spliterator<? extends T> itr) Wraps the providedSpliteratorto aFastStream.static <T> FastStream<T>Wrap the provided JavaStreamto aFastStream.static <T> FastStream<T>of(T thing) Returns aFastStreamfor a single object.static <T> FastStream<T>of(T... things) Returns aFastStreamfor an array of objects.static <T> FastStream<T>ofNullable(T thing) Returns aFastStreamfor a single object.default Tonly()default Tdefault TonlyOrDefault(T _default) default FastStream<T>Returns aFastStreamwhich listens to all the elements which pass to the next operation.default FastStream<T>reversed()Returns aFastStreamin reverse order.default FastStream<T>skip(@org.jetbrains.annotations.Range(from=0L, to=2147483647L) int n) Returns aFastStreamwhich will skipnnumber of elements.default FastStream<T>sorted()Returns aFastStreamsorted based on the elements natural sort order.default FastStream<T>sorted(Comparator<? super T> comparator) Returns aFastStreamsorted based on the provided comparator.default Object[]toArray()Collects this stream into anObject[].default T[]Collects the stream into aT[].default com.google.common.collect.ImmutableList<T>Collects this stream into aImmutableList.default <R> com.google.common.collect.ImmutableList<R>toImmutableList(FastStream.TypeCheck<R, ? super T> check) Collects this stream into aImmutableList.default <K,V> com.google.common.collect.ImmutableMap<K, V> toImmutableMap(Function<? super T, ? extends K> kFunc, Function<? super T, ? extends V> vFunc) Collects this stream into anImmutableMap.default <K,V> com.google.common.collect.ImmutableMap<K, V> toImmutableMap(Function<? super T, ? extends K> kFunc, Function<? super T, ? extends V> vFunc, BinaryOperator<V> mergeFunc) Collects this stream into anImmutableMap.default com.google.common.collect.ImmutableSet<T>Collects this stream into aImmutableSet.default <R> com.google.common.collect.ImmutableSet<R>toImmutableSet(FastStream.TypeCheck<R, ? super T> check) Collects this stream into aImmutableSet.default <K,V> LinkedHashMap<K, V> toLinkedHashMap(Function<? super T, ? extends K> kFunc, Function<? super T, ? extends V> vFunc) Collects this stream into aLinkedHashMap.default <K,V> LinkedHashMap<K, V> toLinkedHashMap(Function<? super T, ? extends K> kFunc, Function<? super T, ? extends V> vFunc, BinaryOperator<V> mergeFunc) Collects this stream into aLinkedHashMap.default LinkedHashSet<T>Collects this stream into aLinkedHashSet.default <R> LinkedHashSet<R>toLinkedHashSet(FastStream.TypeCheck<R, ? super T> check) Collects this stream into aLinkedHashSet.default LinkedList<T>Collects this stream into aLinkedList.default <R> LinkedList<R>toLinkedList(FastStream.TypeCheck<R, ? super T> check) Collects this stream into aLinkedList.toList()Collects this stream into anArrayList.default <R> List<R>toList(FastStream.TypeCheck<R, ? super T> check) Collects this stream into anArrayList.default <K,V> HashMap<K, V> Collects this stream into aHashMap.default <K,V> HashMap<K, V> toMap(Function<? super T, ? extends K> kFunc, Function<? super T, ? extends V> vFunc, BinaryOperator<V> mergeFunc) Collects this stream into aHashMap.default <K,V, M extends Map<K, V>>
MCollects this stream into the providedMap.default <K,V, M extends Map<K, V>>
MtoMap(M map, Function<? super T, ? extends K> kFunc, Function<? super T, ? extends V> vFunc, BinaryOperator<V> mergeFunc) Collects this stream into the providedMap.toSet()Collects this stream into aHashSet.default <R> HashSet<R>toSet(FastStream.TypeCheck<R, ? super T> check) Collects this stream into aHashSet.从接口继承的方法 java.lang.Iterable
forEach, iterator, spliterator
-
字段详细资料
-
EMPTY
Static empty instance. You wantempty()for return type inference.
-
-
方法详细资料
-
empty
Returns an emptyFastStreamsingleton.- 返回:
- An empty
FastStream.
-
of
Overload ofempty()for convenience.- 返回:
- An empty
FastStream.
-
of
Wraps the providedIterableto aFastStreamThis method may return the same object if it's already a
FastStream, the empty singleton if it's aCollectionand provably empty, or a new Wrapped instance.The Wrapped instance is careful to expose the underlying iterator of the provided
Iterable, as well as forward calls toIterable.forEach(java.util.function.Consumer<? super T>)- 参数:
itr- TheIterableto wrap.- 返回:
- The wrapped Iterable.
-
of
Wraps the providedSpliteratorto aFastStream.- 参数:
itr- TheSpliterator.- 返回:
- The
FastStream
-
of
Wrap the provided JavaStreamto aFastStream.This method is provided to support wrapping API's which only provide
Streamoutputs, intoFastStream. This implicitly uses theof(Spliterator).Where possible, raw
SpliteratororIteratorinputs should be used.NOTE: Using Java
Streamoperations combined withFastStreamoperations may result in poor performance.- 参数:
stream- The stream.- 返回:
- The
FastStream
-
of
Returns aFastStreamfor a single object.- 参数:
thing- The thing.- 返回:
- The
FastStreamfor the single object.
-
ofNullable
Returns aFastStreamfor a single object.If the provided object is
null, an emptyFastStreamis returned.- 参数:
thing- The thing.- 返回:
- The
FastStreamfor the single object or empty.
-
of
Returns aFastStreamfor anOptional.If the provided
Optionalis notOptional.isPresent(), an emptyFastStreamis returned.- 参数:
opt- TheOptional.- 返回:
- The
FastStreamfor theOptionalor empty.
-
of
Returns aFastStreamfor an array of objects.This method is preferred over a wrapper such as
Arrays.asList(T...)due to fewer allocations and virtual/interface calls.- 参数:
things- The thing.- 返回:
- The
FastStreamfor the objects.
-
concat
Returns a concatenatedFastStreamcontaining the elements from the providedIterablearray.- 参数:
iterables- TheIterables to concatenate.- 返回:
- The concatenated
FastStream.
-
concatMany
- 参数:
iterables- TheIterables to concatenate.- 返回:
- The concatenated
FastStream.
-
infer
Used to nudge Javac to perform looser inference on return types of some collecting functions provided in here. -
concat
Returns aFastStreamwith the providedIterableconcatenated after.- 参数:
other- The other- 返回:
- THe concatenated
FastStream.
-
filter
Returns aFastStreamcontaining all elements that pass the providedPredicatefilter.- 参数:
pred- ThePredicateto apply.- 返回:
- The filtered
FastStream.
-
filterNot
Returns aFastStreamcontaining all elements that fail the providedPredicatefilter.- 参数:
pred- ThePredicateto apply.- 返回:
- The filtered
FastStream.
-
map
Returns aFastStreamwith each element transformed by the providedFunction.- 参数:
func- TheFunctionto apply.- 返回:
- The transformed
FastStream.
-
flatMap
Returns aFastStreamwith each element transformed by the providedFunctionconcatenated together.- 参数:
func- TheFunctionto apply producing theIterablefor concatenation.- 返回:
- The flat mapped
FastStream.
-
distinct
Returns aFastStreamcontaining all elements that are unique according to theirObject.hashCode()/Object.equals(java.lang.Object)identity.- 返回:
- The distinct filtered
FastStream.
-
groupBy
Returns aFastStreamcontaining all elements grouped by a key. The providedFunctionis used to extract the key from the element.- 参数:
keyFunc- The keyFunction.- 返回:
- The Grouped
FastStream
-
groupBy
default <K,V> FastStream<FastStream.Group<K,V>> groupBy(Function<? super T, ? extends K> keyFunc, Function<? super T, ? extends V> valueFunc) Returns aFastStreamcontaining all elements grouped by a key. The providedFunctionis used to extract the key from the element.- 参数:
keyFunc- The keyFunction.valueFunc- The valueFunction.- 返回:
- The Grouped
FastStream
-
sorted
Returns aFastStreamsorted based on the elements natural sort order.This requires that
TimplementsComparable.- 返回:
- The sorted
FastStream.
-
sorted
Returns aFastStreamsorted based on the provided comparator.- 参数:
comparator- TheComparatorto apply.- 返回:
- The sorted
FastStream.
-
reversed
Returns aFastStreamin reverse order.- 返回:
- The reversed
FastStream.
-
peek
Returns aFastStreamwhich listens to all the elements which pass to the next operation.- 参数:
cons- The listenerConsumer.- 返回:
- The
FastStream.
-
limit
Returns aFastStreamwhich will let at mostmaxelements pass.A special case of
-1is provided to indicate no max limit.- 参数:
max- The maximum amount of elements to pass through, or-1.- 返回:
- The limited
FastStream.
-
skip
Returns aFastStreamwhich will skipnnumber of elements.- 参数:
n- The number of elements to skip.- 返回:
- The skipping
FastStream.
-
anyMatch
Tests if any element in theFastStreammatches the providedPredicate. -
allMatch
Tests if all elements in theFastStreammatch the providedPredicate. -
noneMatch
Tests if no elements in theFastStreammatch the providedPredicate. -
isEmpty
default boolean isEmpty()Tests if the stream is empty.This method is provided for convenience. Generally, using
knownLength()or a collecting operation would achieve greater performance.- 返回:
- If the stream is empty.
-
knownLength
default int knownLength()Returns the known length for the stream.This may return
-1if the stream contains operations that can't know their length before computing (filter operations).- 返回:
- The known length, or
-1
-
knownLength
default int knownLength(boolean consumeToCalculate) Returns the known length for the stream.If
trueis specified toconsumeToCalculatecauses operations which would not normally know their length prior to a terminal operation being applied, to cache their result under the assumption that the stream is about to be fully consumed.- 参数:
consumeToCalculate- If the caller intends to consume the entire stream viaIterable.forEach(java.util.function.Consumer<? super T>)after calling.- 返回:
- The known length for the stream. {code -1} if the length is not known.
-
count
default int count()Evaluates the stream, counting the number of elements contained within.- 返回:
- The number of elements in the stream.
-
fold
@Nullable @Contract("!null,_ -> !null") default <U> U fold(@Nullable U identity, BiFunction<? super @Nullable U, ? super T, ? extends U> accumulator) Returns the result of a folding operation applied to theFastStreamcontents.- 参数:
identity- The initial value.accumulator- TheFunctionresponsible for merging elements in the stream together.- 返回:
- The result of the fold operation. May be
nullifidentityis null and the stream is empty.
-
fold
Returns the result of a folding operation applied to theFastStreamcontents.- 参数:
accumulator- TheFunctionresponsible for merging elements in the stream together.- 返回:
- Optionally, the result of the fold operation.
Will be empty if the
FastStreamcontained no elements.
-
intSum
Sum all elements in the stream to an integer, using the providedToIntFunctionto convert each element to an integer.- 参数:
func- TheToIntFunctionto apply.- 返回:
- The sum of the elements.
-
longSum
Sum all elements in the stream to a long, using the providedToLongFunctionto convert each element to a long.- 参数:
func- TheToLongFunctionto apply.- 返回:
- The sum of the elements.
-
doubleSum
Sum all elements in the stream to a double, using the providedToDoubleFunctionto convert each element to a double.- 参数:
func- TheToDoubleFunctionto apply.- 返回:
- The sum of the elements.
-
findFirst
- 返回:
- Optionally, the first element in the stream.
-
first
- 返回:
- The first element in the stream.
-
firstOrDefault
- 返回:
- The first element in the stream, or
null.
-
firstOrDefault
- 参数:
_default- The default value to return if the stream is empty.- 返回:
- The first element in the stream, or
_default.
-
findLast
- 返回:
- Optionally, the last element in the stream.
-
last
- 返回:
- The last element in the stream.
-
lastOrDefault
- 返回:
- The last element in the stream, or
null.
-
lastOrDefault
- 参数:
_default- The default value to return if the stream is empty.- 返回:
- The last element in the stream, or
_default.
-
only
- 返回:
- Returns the only element in the stream.
-
onlyOrDefault
- 返回:
- Returns the only element in the steam.
nullif the stream is empty or contains more than one element.
-
onlyOrDefault
- 参数:
_default- The default value to return if the stream is empty or contains more than one element.- 返回:
- Returns the only element in the stream.
_defaultif the stream is empty or contains more than one element.
-
maxBy
Returns the element in the stream with the highest value returned by the providedToIntFunction.- 参数:
func- TheToIntFunction.- 返回:
- The maximum value.
-
maxByOrDefault
Returns the element in the stream with the highest value returned by the providedToIntFunction.- 参数:
func- TheToIntFunction.- 返回:
- The maximum value or
nullif the stream is empty.
-
maxByOrDefault
@Nullable @Contract("_,!null->!null") default T maxByOrDefault(ToIntFunction<T> func, @Nullable T _default) Returns the element in the stream with the highest value returned by the providedToIntFunction.- 参数:
func- TheToIntFunction._default- The default value to return if the stream is empty.- 返回:
- The maximum value or
_defaultif the stream is empty.
-
toList
Collects this stream into anArrayList.- 返回:
- The
ArrayList.
-
toList
Collects this stream into anArrayList. -
toLinkedList
Collects this stream into aLinkedList.- 返回:
- The
LinkedList.
-
toLinkedList
Collects this stream into aLinkedList.- 参数:
check- Callinfer()in this argument for flexible return inference.- 返回:
- The
LinkedList.
-
toImmutableList
Collects this stream into aImmutableList.- 返回:
- The
ImmutableList.
-
toImmutableList
default <R> com.google.common.collect.ImmutableList<R> toImmutableList(FastStream.TypeCheck<R, ? super T> check) Collects this stream into aImmutableList.- 参数:
check- Callinfer()in this argument for flexible return inference.- 返回:
- The
ImmutableList.
-
toSet
Collects this stream into aHashSet.- 返回:
- The
HashSet.
-
toSet
Collects this stream into aHashSet. -
toLinkedHashSet
Collects this stream into aLinkedHashSet.- 返回:
- The
LinkedHashSet.
-
toLinkedHashSet
Collects this stream into aLinkedHashSet.- 参数:
check- Callinfer()in this argument for flexible return inference.- 返回:
- The
LinkedHashSet.
-
toImmutableSet
Collects this stream into aImmutableSet.- 返回:
- The
ImmutableSet.
-
toImmutableSet
default <R> com.google.common.collect.ImmutableSet<R> toImmutableSet(FastStream.TypeCheck<R, ? super T> check) Collects this stream into aImmutableSet.- 参数:
check- Callinfer()in this argument for flexible return inference.- 返回:
- The
ImmutableSet.
-
toArray
Collects this stream into anObject[].- 返回:
- The
Object[].
-
toArray
Collects the stream into aT[].- 参数:
arr- The template array to use. If the array is large enough to fit all elements in the stream, this will be used with a singlenullelement after the last element.- 返回:
- The
T[].
-
toMap
default <K,V> HashMap<K,V> toMap(Function<? super T, ? extends K> kFunc, Function<? super T, ? extends V> vFunc) Collects this stream into aHashMap.In the event of a collision, the first value will be used.
-
toMap
default <K,V> HashMap<K,V> toMap(Function<? super T, ? extends K> kFunc, Function<? super T, ? extends V> vFunc, BinaryOperator<V> mergeFunc) Collects this stream into aHashMap.- 参数:
kFunc- TheFunctionto extracting the key.vFunc- TheFunctionto extracting the value.mergeFunc- TheBinaryOperatorto resolve merge conflicts.- 返回:
- The
HashMap.
-
toLinkedHashMap
default <K,V> LinkedHashMap<K,V> toLinkedHashMap(Function<? super T, ? extends K> kFunc, Function<? super T, ? extends V> vFunc) Collects this stream into aLinkedHashMap.In the event of a collision, the first value will be used.
- 参数:
kFunc- TheFunctionto extracting the key.vFunc- TheFunctionto extracting the value.- 返回:
- The
LinkedHashMap.
-
toLinkedHashMap
default <K,V> LinkedHashMap<K,V> toLinkedHashMap(Function<? super T, ? extends K> kFunc, Function<? super T, ? extends V> vFunc, BinaryOperator<V> mergeFunc) Collects this stream into aLinkedHashMap.- 参数:
kFunc- TheFunctionto extracting the key.vFunc- TheFunctionto extracting the value.mergeFunc- TheBinaryOperatorto resolve merge conflicts.- 返回:
- The
LinkedHashMap.
-
toImmutableMap
default <K,V> com.google.common.collect.ImmutableMap<K,V> toImmutableMap(Function<? super T, ? extends K> kFunc, Function<? super T, ? extends V> vFunc) Collects this stream into anImmutableMap.In the event of a collision, the first value will be used.
-
toImmutableMap
default <K,V> com.google.common.collect.ImmutableMap<K,V> toImmutableMap(Function<? super T, ? extends K> kFunc, Function<? super T, ? extends V> vFunc, BinaryOperator<V> mergeFunc) Collects this stream into anImmutableMap.- 参数:
kFunc- TheFunctionto extracting the key.vFunc- TheFunctionto extracting the value.mergeFunc- TheBinaryOperatorto resolve merge conflicts.- 返回:
- The
ImmutableMap.
-
toMap
default <K,V, M toMapM extends Map<K, V>> (M map, Function<? super T, ? extends K> kFunc, Function<? super T, ? extends V> vFunc) Collects this stream into the providedMap.In the event of a collision, the first value will be used.
-
toMap
default <K,V, M toMapM extends Map<K, V>> (M map, Function<? super T, ? extends K> kFunc, Function<? super T, ? extends V> vFunc, BinaryOperator<V> mergeFunc) Collects this stream into the providedMap.- 参数:
kFunc- TheFunctionto extracting the key.vFunc- TheFunctionto extracting the value.mergeFunc- TheBinaryOperatorto resolve merge conflicts.- 返回:
- The
Map.
-
join
Join all elements of this stream together into aString, separated bysep.This function will use the element's
Object.toString().- 参数:
sep- The seperator.- 返回:
- The joined
String.
-