"collect" method

1.The collect is declared by the Interface of Stream.The param is Collector Interface.

<R, A> R collect(Collector<? super T, A, R> collector);

2.The Collector Interface mainly contains 4 functions about:

  (1)creation of a new result container ({@link #supplier()})

  (2)incorporating a new data element into a result container ({@link #accumulator()})

  (3)combining two result containers into one ({@link #combiner()})

  (4)performing an optional final transform on the container ({@link #finisher()}

3.The Collectors Class has a inner class which implements above Collector.So you can invoke collect by this assistant class (Collectors).The Collectors class implement some common operations.

  ex:

public static <T>
    Collector<T, ?, List<T>> toList() {
        return new CollectorImpl<>((Supplier<List<T>>) ArrayList::new, List::add,
                                   (left, right) -> { left.addAll(right); return left; },
                                   CH_ID);
    }

  

  

时间: 2024-08-04 09:24:39

"collect" method的相关文章

[pySpark][笔记]spark tutorial from spark official site在ipython notebook 下学习pySpark

+ Spark Tutorial: Learning Apache Spark This tutorial will teach you how to use Apache Spark, a framework for large-scale data processing, within a notebook. Many traditional frameworks were designed to be run on a single computer. However, many data

基础知识(2)- Java SE 8 Programmer II (1z0-809)

Java Class Design Implement encapsulation Implement inheritance including visibility modifiers and composition Implement polymorphism Override hashCode, equals, and toString methods from Object class Create and use singleton classes and immutable cla

Chapter 10 - Object lifetime

1. Class, object and reference Recall that class is nothing more than a blueprint that describes how an instance of this type will look and feel in memory. And they are defined within a code file (.cs in C#). After a class has been defined, you may a

Fundamentals of Garbage Collection

[Fundamentals of Garbage Collection] 1.Reclaims objects that are no longer being used, clears their memory, and keeps the memory available for future allocations. Managed objects automatically get clean content to start with, so their constructors do

The method&#39;s class, com.google.common.collect.FluentIterable, is available from the following locations

报以下错误,是因为guava版本冲突. Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2019-11-13 14:00:06.535 ERROR 18640 --- [restartedMain] o.s.b.d.LoggingFailureAnalysisReporter : *******************

DDoS ATTACK PROCESSING APPARATUS AND METHOD IN OPENFLOW SWITCH

An OpenFlow switch in an OpenFlow environment includes an?attack determination module to collect statistical information on packet processing with respect to incoming packets to be processed in the OpenFlow switch at a predetermined period interval t

SolrCore &#39;collection1&#39; is not available due to init failure: Index locked for write for core collect

org.apache.solr.common.SolrException: SolrCore 'collection1' is not available due to init failure: Index locked for write for core collection1 at org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:753) at org.apache.solr.client.solrj.embed

PatentTips - Method and system for browsing things of internet of things on ip using web platform

BACKGROUND The following disclosure relates to a method and system for enabling a user to browse physical things using a rich user interface (UI) via a web browser in Internet of Things (IoT) such that an end user has rich experience. Internet of Thi

PatentTips - Method, apparatus and system for instructing a virtual device from a virtual machine

BACKGROUND OF THE INVENTION A virtual machine (VM) may be or include a framework or environment created by for example a virtual machine monitor (VMM) on a host system. A VMM may provide facilities or resources on a host environment for an applicatio