count (统计操作符)
目录
1 count接口
Single<Long> |
count() 返回一个Single,它计算源Publisher发出的项目总数,并将此计数作为64位Long计算。 |
2 count图解
源码中关于count的图解地址是有问题的,count仅仅是统计发射项目数目,没有做判断,可自行查看
3 count测试用例
测试代码
@Test
public void count() {
System.out.println("######contains#####");
Single<Long> single = Flowable.just("李晓明", "张宝庆","赵无极").count();
single.subscribe(new Consumer<Long>() {
@Override
public void accept(Long count) throws Exception {
System.out.println("发射项目总数 count = " + count);
}
});
}
测试结果
######contains#####
发射项目总数 count = 3
3 count测试用例说明
count计数的意思,很好理解,就是计算Publisher发射项目的个数