Stream (Java)

rolroralra·2022년 9월 23일
0

stream

목록 보기
2/3
post-thumbnail

Intermediate Operation (중간 연산)

OperationStatelessStyleReturn TypeParameterFunction DescriptorDescription
filterFilteringStreamPredicateT -> boolean
distinctstateful, unboundFilteringStream
sortedstateful, unboundSortingStreamComparator(T, T) -> int
takeWhileSlicingStreamPredicateT -> booleanlimit
dropWhileSlicingStreamPredicateT -> booleanskip
limitstateful, boundSlicingStreamlongshort circuit
skipstateful, boundSlicingStreamlong
mapMappingStreamFunction<T, R>T -> R
flatMapMappingStreamFunction<T, Stream>T -> Stream

Terminal Operation (최종 연산)

OperationStatelessStyleReturn TypeParameterFunction DescriptorDescription
anyMatchMatchingbooleanPredicateT -> booleanshort circuit
allMatchMatchingbooleanPredicateT -> booleanshort circuit
noneMatchMatchingbooleanPredicateT -> booleanshort circuit
findAnyFindingOptional
findFirstFindingOptional
forEachIterationvoidConsumerT -> void
collectReduceRCollector<T, A, R>Supplier supplier

BiConsumer<A, T> accumulator

BinaryOperator
combiner

Function<A, R> finisher
reducestateful, boundReduceOptionalBinaryOperator(T, T) -> T
countReducelong

Filtering

OperationOperation TypeStyleReturn TypeParameterFunction DescriptorDescription
filterintermediateFilteringStreamPredicateT -> boolean
distinctintermediateFilteringStream

Slicing

OperationOperation TypeStyleReturn TypeParameterFunction DescriptorDescription
takeWhileintermediateSlicingStreamPredicateT -> booleanlimit
dropWhileintermediateSlicingStreamPredicateT -> booleanskip
limitintermediateSlicingStreamlongshort circuit
skipintermediateSlicingStreamlong

Mapping

OperationOperation TypeStyleReturn TypeParameterFunction DescriptorDescription
mapintermediateMappingStreamFunction<T, R>T -> R
flatMapintermediateMappingStreamFunction<T, R>T -> Stream

Matching

OperationOperation TypeStyleReturn TypeParameterFunction DescriptorDescription
anyMatchterminalMatchingbooleanPredicateT -> booleanshort circuit
allMatchterminalMatchingbooleanPredicateT -> booleanshort circuit
noneMatchterminalMatchingbooleanPredicateT -> booleanshort circuit

Finding

OperationOperation TypeStyleReturn TypeParameterFunction DescriptorDescription
findAnyterminalFindingOptionalShort Circuit
findFirstterminalFindingOptionalShort Circuit

Reduce (Fold)

OperationOperation TypeStyleReturn TypeParameterFunction DescriptorDescription
forEachterminalIterationvoidConsumerT -> void
collectterminalReduceRCollector<T, A, R>Supplier supplier

BiConsumer<A, T> accumulator

BinaryOperator
combiner

Function<A, R> finisher
reducetermianlReduceOptionalBinaryOperator(T, T) -> T
countterminalReducelong

Collector

interface Collector<T, A, R> {
  Supplier<A> supplier();
  BiConsumer<A, T> accumulator();
  BinaryOperator<A> combiner();
  Function<A, R> finisher();
  Set<Characteristics> characteristics();
}
Static MethodCollector Type (Return Type)Collect Type (Reduce Type)Parameter Types
toListCollector<T, ?, List>List
toSetCollector<T, ?, Set>Set
toCollectionCollector<T, ?, C>C extends CollectionSupplier
joiningCollector<CharSequence, ?, String>StringCharSequence delimiter (optional)
CharSequence prefix (optional)
CharSequence suffix (optional)
countingCollector<T, ?, Long>Long
summingInt
summingLong
summingDouble
Collector<T, ?, Integer>
Collector<T, ?, Long>
Collector<T, ?, Double>
Integer
Long
Double
ToIntFunction<? super T>
ToLongFunction<? super T>
ToDoubleFunction<? super T>
averagingInt
averagingLong
averagingDouble
Collector<T, ?, Double>
Collector<T, ?, Double>
Collector<T, ?, Double>
Double
Double
Double
ToIntFunction<? super T>
ToLongFunction<? super T>
ToDoubleFunction<? super T>
summarizingInt
summarizingLong
summarizingDouble
Collector<T, ?, IntSummaryStatistics>
Collector<T, ?, LongSummaryStatistics>
Collector<T, ?, DoubleSummaryStatistics>
IntSummaryStatistics
LongSummaryStatistics
DoubleSummaryStatistics
ToIntFunction<? super T>
ToLongFunction<? super T>
ToDoubleFunction<? super T>
maxByCollector<T, ?, Optional>OptionalComparator<? super T>
minByCollector<T, ?, Optional>OptionalComparator<? super T>
mappingCollector<T, ?, R>RFunction<? super T, ? extends U> mapper
Collector<? super U, A, R> downstream
flatMappingCollector<T, ?, R>RFunction<? super T, ? extends Stream<? extends U>> mapper
Collector<? super U, A, R> downstream
filteringCollector<T, ?, R>RPredicate<? super T> predicate
Collector<? super T, A, R> downstream
reducingCollector<T, ?, T>
Collector<T, ?, Optional>
Collector<T, ?, U>
T
Optional
U
T identity, BinaryOperator op
BinaryOperator op
U identity, Function<? super T, ? extends U> mapper, BinaryOperator op
collectingAndThenCollector<T, A, RR>RRCollector<T, A, R> downstream, Function<R, RR> finisher
groupingByCollector<T, ?, Map<K, List>>
Collector<T, ?, Map<K, D>>
Collector<T, ?, M>
Map<K, List>
Map<K, D>
M extends Map<K, D>
Function<? super T, ? extends K> classfier
Function<? super T, ? extends K> classfier, Collector<? super T, A, D> downstream
Function<? super T, ? extends k> classfier, Supplier mapFactory, Collector<? super T, A, D>
partitioningByCollector<T, ?, Map<Boolean, List>>
Collector<T, ?, Map<Boolean, D>
Map<Boolean, List>
Map<Boolean, D>
Predicate<? super T> predicate
Predicate<? super T> predicate, Collector<? super T, A, D> downstream
teeingCollector<T, ?, R>RCollector<? super T, ?, R1> downstream1, Collector<? super T, ?, R2> downstream2, BiFunction<? super R1, ? super R2, R> merger

Parallel Stream

https://n1tjrgns.tistory.com/292


Comparator

public interface Comparator<T> {
  int compare(T o1, T o2);
}
Static MethodParameter TypesReturn Type
comparingFunction<? super T, ? extends U> keyExtractor,
Comparator<? super U> keyComparator (optional)
Comparator
comparingInt
comparingLong
comparingDouble
ToIntFunction<? super T> keyExtractor
ToLongFunction<? super T> keyExtractor
ToDoubleFunction<? super T> keyExtractor
Comparator
naturalOrderComparator
reverseOrderComparator
nullsFirstComparator<? super T> comparatorComparator
nullsLastComparator<? super T> comparatorComparator
profile
Hello velog!

0개의 댓글