toList ( )源码实例Demo

java.util.stream.Collectors#toList ( )源码实例Demo

下面列出了java.util.stream.Collectors#toList ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Test
public void testParSquaresResults() throws Exception {
    int count = 15;
    var keys = new ArrayList<>(demos.keySet());
    var demo1 = demos.get(keys.get(0));
    var demo2 = demos.get(keys.get(1));
    var demo3 = demos.get(keys.get(2));
    var join = Collectors.toList();
    var r1 = demo1.doParallelSquaresAsync(count).get().stream().sorted().collect(join);
    var r2 = demo2.doParallelSquaresAsync(count).get().stream().sorted().collect(join);
    var r3 = demo3.doParallelSquaresAsync(count).get().stream().sorted().collect(join);
    assertEquals(demo1.getClass() + " != " + demo2.getClass(), r1, r2);
    assertEquals(demo3.getClass() + " != " + demo2.getClass(), r3, r2);
}
 
源代码2 项目: cyclops   文件: SpoutsTest.java
@Test
public void testCollector(){
    Collector<Integer, ?, List<Integer>> list = Collectors.toList();
    List<Integer> res= null;
    res =Stream.of(1,2,3)
                .map(i->i+2)
                .collect(list);
    System.out.println("res " + res);
 //   Stream.of(1,2,3).collect((Supplier)list.supplier(),list.accumulator(),list.combiner());
}
 
源代码3 项目: spring-cloud-gcp   文件: PartTreeDatastoreQuery.java
/**
 * Based on the query options, returns a collector that puts Datastore query results
 * in a correct form.
 *
 * @return collector
 */
private Collector<?, ?, ?> getResultsCollector() {
	Collector<?, ?, ?> collector  = Collectors.toList();
	if (isCountingQuery && !PartTreeDatastoreQuery.this.tree.isDelete()) {
		collector = Collectors.counting();
	}
	else if (PartTreeDatastoreQuery.this.tree.isExistsProjection()) {
		collector = Collectors.collectingAndThen(Collectors.counting(), (count) -> count > 0);
	}
	return collector;
}
 
源代码4 项目: attic-polygene-java   文件: Annotations.java
public static List<Annotation> findAccessorAndTypeAnnotationsIn(AccessibleObject accessor) {
    Stream<Annotation> stream = Stream.concat(
            Arrays.stream(accessor.getAnnotations()),
            interfacesOf(typeOf(accessor)).flatMap(ANNOTATIONS_OF)
    );
    Collector<Annotation, ?, List<Annotation>> collector = Collectors.toList();
    return stream.collect(collector);
}
 
源代码5 项目: dragonwell8_jdk   文件: MapBinToFromTreeTest.java
Collector<Integer, ?, ? extends Collection<Integer>> getCollector(Map<?, ?> m) {
    Collector<Integer, ?, ? extends Collection<Integer>> collector = m instanceof LinkedHashMap
                                                                     ? Collectors.toList()
                                                                     : Collectors.toSet();
    return collector;
}
 
源代码6 项目: TencentKona-8   文件: MapBinToFromTreeTest.java
Collector<Integer, ?, ? extends Collection<Integer>> getCollector(Map<?, ?> m) {
    Collector<Integer, ?, ? extends Collection<Integer>> collector = m instanceof LinkedHashMap
                                                                     ? Collectors.toList()
                                                                     : Collectors.toSet();
    return collector;
}
 
@Test
public void collect() {
    Collector collector = Collectors.toList();
    Graph graph = graphFor(builder().collect(collector));
    assertSame(getAddedStage(Stage.Collect.class, graph).getCollector(), collector);
}
 
源代码8 项目: cyclops   文件: Vector.java
static <T> Collector<T, List<T>, Vector<T>> collector() {
    Collector<T, ?, List<T>> c  = Collectors.toList();
    return Collectors.<T, List<T>, Iterable<T>,Vector<T>>collectingAndThen((Collector)c,Vector::fromIterable);
}
 
源代码9 项目: cyclops   文件: LazyString.java
static Collector<Character, List<Character>, LazyString> collector() {
    Collector<Character, ?, List<Character>> c  = Collectors.toList();
    return Collectors.<Character, List<Character>, Iterable<Character>,LazyString>collectingAndThen((Collector)c,LazyString::fromIterable);
}
 
源代码10 项目: cyclops   文件: BankersQueue.java
static <T> Collector<T, List<T>, BankersQueue<T>> collector() {
    Collector<T, ?, List<T>> c  = Collectors.toList();
    return Collectors.<T, List<T>, Iterable<T>,BankersQueue<T>>collectingAndThen((Collector)c,BankersQueue::fromIterable);
}
 
源代码11 项目: jdk8u-jdk   文件: MapBinToFromTreeTest.java
Collector<Integer, ?, ? extends Collection<Integer>> getCollector(Map<?, ?> m) {
    Collector<Integer, ?, ? extends Collection<Integer>> collector = m instanceof LinkedHashMap
                                                                     ? Collectors.toList()
                                                                     : Collectors.toSet();
    return collector;
}
 
Collector<Integer, ?, ? extends Collection<Integer>> getCollector(Map<?, ?> m) {
    Collector<Integer, ?, ? extends Collection<Integer>> collector = m instanceof LinkedHashMap
                                                                     ? Collectors.toList()
                                                                     : Collectors.toSet();
    return collector;
}
 
源代码13 项目: jdk8u-dev-jdk   文件: MapBinToFromTreeTest.java
Collector<Integer, ?, ? extends Collection<Integer>> getCollector(Map<?, ?> m) {
    Collector<Integer, ?, ? extends Collection<Integer>> collector = m instanceof LinkedHashMap
                                                                     ? Collectors.toList()
                                                                     : Collectors.toSet();
    return collector;
}
 
源代码14 项目: cyclops   文件: LazySeq.java
static <T> Collector<T, List<T>, LazySeq<T>> collector() {
    Collector<T, ?, List<T>> c  = Collectors.toList();
    return Collectors.<T, List<T>, Iterable<T>,LazySeq<T>>collectingAndThen((Collector)c,LazySeq::fromIterable);
}
 
源代码15 项目: hottub   文件: MapBinToFromTreeTest.java
Collector<Integer, ?, ? extends Collection<Integer>> getCollector(Map<?, ?> m) {
    Collector<Integer, ?, ? extends Collection<Integer>> collector = m instanceof LinkedHashMap
                                                                     ? Collectors.toList()
                                                                     : Collectors.toSet();
    return collector;
}
 
源代码16 项目: openjdk-8-source   文件: MapBinToFromTreeTest.java
Collector<Integer, ?, ? extends Collection<Integer>> getCollector(Map<?, ?> m) {
    Collector<Integer, ?, ? extends Collection<Integer>> collector = m instanceof LinkedHashMap
                                                                     ? Collectors.toList()
                                                                     : Collectors.toSet();
    return collector;
}
 
源代码17 项目: openjdk-8   文件: MapBinToFromTreeTest.java
Collector<Integer, ?, ? extends Collection<Integer>> getCollector(Map<?, ?> m) {
    Collector<Integer, ?, ? extends Collection<Integer>> collector = m instanceof LinkedHashMap
                                                                     ? Collectors.toList()
                                                                     : Collectors.toSet();
    return collector;
}
 
源代码18 项目: jdk8u_jdk   文件: MapBinToFromTreeTest.java
Collector<Integer, ?, ? extends Collection<Integer>> getCollector(Map<?, ?> m) {
    Collector<Integer, ?, ? extends Collection<Integer>> collector = m instanceof LinkedHashMap
                                                                     ? Collectors.toList()
                                                                     : Collectors.toSet();
    return collector;
}
 
源代码19 项目: cyclops   文件: Seq.java
static <T> Collector<T, List<T>, Seq<T>> collector() {
    Collector<T, ?, List<T>> c  = Collectors.toList();
    return Collectors.<T, List<T>, Iterable<T>,Seq<T>>collectingAndThen((Collector)c,Seq::fromIterable);
}
 
源代码20 项目: essentials4j   文件: To.java
/**
 * Returns a {@code Collector} that accumulates the input elements into a new {@code List}.
 * <p>
 * A shortcut for: {@code Collectors.toList()}.
 *
 * @param <T> the type of the output list elements
 * @return a new collector that accumulates the input elements into a new {@code List}
 * @see Collectors#toList()
 */
public static <T> Collector<T, ?, List<T>> list() {
	return Collectors.toList();
}