/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved. <a>http://www.crunii.com</a>
 */
package com.crunii.micro.gateway.test;

import java.util.List;

import com.google.common.collect.Lists;

/**
 * @author 田平 create 2018年6月8日上午10:54:34
 */
public class ReactorTest {
	public static void main(String[] args) throws Exception {
		// Flux.range(1, 100).buffer(20).subscribe(System.out::println);
		// Flux.range(1, 10).bufferUntil(i -> i % 2 == 0).subscribe(System.out::println);
		// Flux.range(1, 10).bufferWhile(i -> i % 2 == 0).subscribe(System.out::println);
		//
		// Flux.range(1, 100).window(20).subscribe(System.out::println);
		// Flux.just("a", "b").zipWith(Flux.just("c", "d")).subscribe(System.out::println);
		//
		// Flux.just("a", "b").zipWith(Flux.just("c", "d"), (s1, s2) -> String.format("%s-%s", s1, s2)).subscribe(System.out::println);
		//
		// Flux.range(1, 5).reduce((x, y) -> x + y).subscribe(System.out::println);
		// Flux.just("flux", "mono").flatMap(s -> Flux.fromArray(s.split("\\s*"))).subscribe(System.out::println);
		// CountDownLatch countDownLatch = new CountDownLatch(1);
		// Flux.zip(Flux.fromArray("abcdef123123123123213123123123123123123123123123123123123123".split("\\s+")), Flux.interval(Duration.ofMillis(1000))) // 3
		// .subscribe(t -> System.out.println(t.getT1()+"_"+t.getT2()), null, countDownLatch::countDown); // 4
		// countDownLatch.await(10, TimeUnit.SECONDS); // 5

		// Flux.range(1, 5).log().publishOn(Schedulers.newParallel("a"))
		// .subscribeOn(Schedulers.newParallel("b")).subscribe(System.out::println);

		
//		Flux.range(0, 10).delayElements(Duration.ofMillis(10)).log().blockLast();
		
//		System.out.println("1111111");
//		List<Integer> ints = Lists.newArrayList(1,2,3,4,5,6,7,8,9,10);
//		System.out.println("ints sum is:" + ints.stream().reduce((sum, item) -> sum + item).get());

		
		//abc222fg
		//ab222
		List<Integer> ints = Lists.newArrayList(1,2,3,4,5,6,7,8,9,10);
		System.out.println(ints.stream().allMatch(item -> item < 100));
		ints.stream().max((o1, o2) -> o1.compareTo(o2)).ifPresent(System.out::println);

	}
}
