IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 开发测试 -> 第四篇 JDK11 Collectors预置的收集器方法 -> 正文阅读

[开发测试]第四篇 JDK11 Collectors预置的收集器方法

java.util.stream.Collectors

修饰符和类型方法描述
static <T>?Collector<T,??,?Double>averagingDouble?(ToDoubleFunction<? super T>?mapper)

返回求输入Double类型元素平均值的Collector

static <T>?Collector<T,??,?Double>averagingInt?(ToIntFunction<? super T>?mapper)返回求输入Interger类型元素平均值的Collector
static <T>?Collector<T,??,?Double>averagingLong?(ToLongFunction<? super T>?mapper)返回求输入Long类型元素平均值的Collector
static <T,?A,?R,?RR>
Collector<T,?A,?RR>
collectingAndThen?(Collector<T,?A,?R>?downstream,?Function<R,?RR>?finisher)

调整收集器在完成收集后应用额外的转换逻辑

static <T>?Collector<T,??,?Long>counting()

返回一个接受T类型元素的Collector,用于统计T元素的个数

static <T,?A,?R>
Collector<T,??,?R>
filtering?(Predicate<? super T>?predicate,?Collector<? super T,?A,?R>?downstream)通过对每个输入元素应用Predicate,使收集器适应于一个接受相同类型T的元素,并只在Predicate返回true时进行累积。 ?
static <T,?U,?A,?R>
Collector<T,??,?R>
flatMapping?(Function<? super T,?? extends?Stream<? extends U>>?mapper,Collector<? super U,?A,?R>?downstream)通过在累积之前对每个输入元素应用Function映射函数,将一个接受U类型元素的收集器调整为一个接受T类型元素。 ?
static <T,?K>
Collector<T,??,?Map<K,?List<T>>>
groupingBy?(Function<? super T,?? extends K>?classifier)

Returns a?Collector?implementing a "group by" operation on input elements of type?T, grouping elements according to a classification function, and returning the results in a?Map.

static <T,?K,?D,?A,?M extendsMap<K,?D>>
Collector<T,??,?M>
groupingBy?(Function<? super T,?? extends K>?classifier,Supplier<M>?mapFactory,?Collector<? super T,?A,?D>?downstream)

Returns a?Collector?implementing a cascaded "group by" operation on input elements of type?T, grouping elements according to a classification function, and then performing a reduction operation on the values associated with a given key using the specified downstream?Collector.

static <T,?K,?A,?D>
Collector<T,??,?Map<K,?D>>
groupingBy?(Function<? super T,?? extends K>?classifier,?Collector<? super T,?A,?D>?downstream)

Returns a?Collector?implementing a cascaded "group by" operation on input elements of type?T, grouping elements according to a classification function, and then performing a reduction operation on the values associated with a given key using the specified downstream?Collector.

static <T,?K>
Collector<T,??,?ConcurrentMap<K,?List<T>>>
groupingByConcurrent?(Function<? super T,?? extends K>?classifier)

Returns a concurrent?Collector?implementing a "group by" operation on input elements of type?T, grouping elements according to a classification function.

static <T,?K,?A,?D,?M extendsConcurrentMap<K,?D>>
Collector<T,??,?M>
groupingByConcurrent?(Function<? super T,?? extends K>?classifier,Supplier<M>?mapFactory,?Collector<? super T,?A,?D>?downstream)

Returns a concurrent?Collector?implementing a cascaded "group by" operation on input elements of type?T, grouping elements according to a classification function, and then performing a reduction operation on the values associated with a given key using the specified downstream?Collector.

static <T,?K,?A,?D>
Collector<T,??,?ConcurrentMap<K,?D>>
groupingByConcurrent?(Function<? super T,?? extends K>?classifier,Collector<? super T,?A,?D>?downstream)

Returns a concurrent?Collector?implementing a cascaded "group by" operation on input elements of type?T, grouping elements according to a classification function, and then performing a reduction operation on the values associated with a given key using the specified downstream?Collector.

staticCollector<CharSequence,??,?String>joining()

Returns a?Collector?that concatenates the input elements into a?String, in encounter order.

staticCollector<CharSequence,??,?String>joining?(CharSequence?delimiter)

Returns a?Collector?that concatenates the input elements, separated by the specified delimiter, in encounter order.

staticCollector<CharSequence,??,?String>joining?(CharSequence?delimiter,?CharSequence?prefix,CharSequence?suffix)

Returns a?Collector?that concatenates the input elements, separated by the specified delimiter, with the specified prefix and suffix, in encounter order.

static <T,?U,?A,?R>
Collector<T,??,?R>
mapping?(Function<? super T,?? extends U>?mapper,?Collector<? super U,?A,?R>?downstream)

Adapts a?Collector?accepting elements of type?U?to one accepting elements of type?T?by applying a mapping function to each input element before accumulation.

static <T>?Collector<T,??,?Optional<T>>maxBy?(Comparator<? super T>?comparator)

Returns a?Collector?that produces the maximal element according to a given?Comparator, described as an?Optional<T>.

static <T>?Collector<T,??,?Optional<T>>minBy?(Comparator<? super T>?comparator)

Returns a?Collector?that produces the minimal element according to a given?Comparator, described as an?Optional<T>.

static <T>?Collector<T,??,?Map<Boolean,?List<T>>>partitioningBy?(Predicate<? super T>?predicate)

Returns a?Collector?which partitions the input elements according to a?Predicate, and organizes them into a?Map<Boolean, List<T>>.

static <T,?D,?A>
Collector<T,??,?Map<Boolean,?D>>
partitioningBy?(Predicate<? super T>?predicate,?Collector<? super T,?A,?D>?downstream)

Returns a?Collector?which partitions the input elements according to a?Predicate, reduces the values in each partition according to another?Collector, and organizes them into a?Map<Boolean, D>?whose values are the result of the downstream reduction.

static <T>?Collector<T,??,?Optional<T>>reducing?(BinaryOperator<T>?op)

Returns a?Collector?which performs a reduction of its input elements under a specified?BinaryOperator.

static <T>?Collector<T,??,?T>reducing?(T?identity,?BinaryOperator<T>?op)

Returns a?Collector?which performs a reduction of its input elements under a specified?BinaryOperator?using the provided identity.

static <T,?U>
Collector<T,??,?U>
reducing?(U?identity,?Function<? super T,?? extends U>?mapper,BinaryOperator<U>?op)

Returns a?Collector?which performs a reduction of its input elements under a specified mapping function and?BinaryOperator.

static <T>?Collector<T,??,?DoubleSummaryStatistics>summarizingDouble?(ToDoubleFunction<? super T>?mapper)

Returns a?Collector?which applies an?double-producing mapping function to each input element, and returns summary statistics for the resulting values.

static <T>?Collector<T,??,?IntSummaryStatistics>summarizingInt?(ToIntFunction<? super T>?mapper)

Returns a?Collector?which applies an?int-producing mapping function to each input element, and returns summary statistics for the resulting values.

static <T>?Collector<T,??,?LongSummaryStatistics>summarizingLong?(ToLongFunction<? super T>?mapper)

Returns a?Collector?which applies an?long-producing mapping function to each input element, and returns summary statistics for the resulting values.

static <T>?Collector<T,??,?Double>summingDouble?(ToDoubleFunction<? super T>?mapper)

Returns a?Collector?that produces the sum of a double-valued function applied to the input elements.

static <T>?Collector<T,??,?Integer>summingInt?(ToIntFunction<? super T>?mapper)

Returns a?Collector?that produces the sum of a integer-valued function applied to the input elements.

static <T>?Collector<T,??,?Long>summingLong?(ToLongFunction<? super T>?mapper)

Returns a?Collector?that produces the sum of a long-valued function applied to the input elements.

static <T,?C extendsCollection<T>>
Collector<T,??,?C>
toCollection?(Supplier<C>?collectionFactory)

Returns a?Collector?that accumulates the input elements into a new?Collection, in encounter order.

static <T,?K,?U>
Collector<T,??,?ConcurrentMap<K,?U>>
toConcurrentMap?(Function<? super T,?? extends K>?keyMapper,?Function<? super T,?? extends U>?valueMapper)

Returns a concurrent?Collector?that accumulates elements into a?ConcurrentMap?whose keys and values are the result of applying the provided mapping functions to the input elements.

static <T,?K,?U>
Collector<T,??,?ConcurrentMap<K,?U>>
toConcurrentMap?(Function<? super T,?? extends K>?keyMapper,?Function<? super T,?? extends U>?valueMapper,?BinaryOperator<U>?mergeFunction)

Returns a concurrent?Collector?that accumulates elements into a?ConcurrentMap?whose keys and values are the result of applying the provided mapping functions to the input elements.

static <T,?K,?U,?M extendsConcurrentMap<K,?U>>
Collector<T,??,?M>
toConcurrentMap?(Function<? super T,?? extends K>?keyMapper,?Function<? super T,?? extends U>?valueMapper,?BinaryOperator<U>?mergeFunction,Supplier<M>?mapFactory)

Returns a concurrent?Collector?that accumulates elements into a?ConcurrentMap?whose keys and values are the result of applying the provided mapping functions to the input elements.

static <T>?Collector<T,??,?List<T>>toList()

Returns a?Collector?that accumulates the input elements into a new?List.

static <T,?K,?U>
Collector<T,??,?Map<K,?U>>
toMap?(Function<? super T,?? extends K>?keyMapper,?Function<? super T,?? extends U>?valueMapper)

Returns a?Collector?that accumulates elements into a?Map?whose keys and values are the result of applying the provided mapping functions to the input elements.

static <T,?K,?U>
Collector<T,??,?Map<K,?U>>
toMap?(Function<? super T,?? extends K>?keyMapper,?Function<? super T,?? extends U>?valueMapper,?BinaryOperator<U>?mergeFunction)

Returns a?Collector?that accumulates elements into a?Map?whose keys and values are the result of applying the provided mapping functions to the input elements.

static <T,?K,?U,?M extendsMap<K,?U>>
Collector<T,??,?M>
toMap?(Function<? super T,?? extends K>?keyMapper,?Function<? super T,?? extends U>?valueMapper,?BinaryOperator<U>?mergeFunction,Supplier<M>?mapFactory)

Returns a?Collector?that accumulates elements into a?Map?whose keys and values are the result of applying the provided mapping functions to the input elements.

static <T>?Collector<T,??,?Set<T>>toSet()

Returns a?Collector?that accumulates the input elements into a new?Set.

static <T>?Collector<T,??,?List<T>>toUnmodifiableList()

Returns a?Collector?that accumulates the input elements into an?unmodifiable List?in encounter order.

static <T,?K,?U>
Collector<T,??,?Map<K,?U>>
toUnmodifiableMap?(Function<? super T,?? extends K>?keyMapper,?Function<? super T,?? extends U>?valueMapper)

Returns a?Collector?that accumulates the input elements into an?unmodifiable Map, whose keys and values are the result of applying the provided mapping functions to the input elements.

static <T,?K,?U>
Collector<T,??,?Map<K,?U>>
toUnmodifiableMap?(Function<? super T,?? extends K>?keyMapper,?Function<? super T,?? extends U>?valueMapper,?BinaryOperator<U>?mergeFunction)

Returns a?Collector?that accumulates the input elements into an?unmodifiable Map, whose keys and values are the result of applying the provided mapping functions to the input elements.

static <T>?Collector<T,??,?Set<T>>toUnmodifiableSet()

Returns a?Collector?that accumulates the input elements into an?unmodifiable Set.

  开发测试 最新文章
pytest系列——allure之生成测试报告(Wind
某大厂软件测试岗一面笔试题+二面问答题面试
iperf 学习笔记
关于Python中使用selenium八大定位方法
【软件测试】为什么提升不了?8年测试总结再
软件测试复习
PHP笔记-Smarty模板引擎的使用
C++Test使用入门
【Java】单元测试
Net core 3.x 获取客户端地址
上一篇文章      下一篇文章      查看所有文章
加:2022-03-16 22:52:05  更:2022-03-16 22:52:40 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/18 0:12:43-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码