• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MathObservable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中rx.observables.MathObservable的典型用法代码示例。如果您正苦于以下问题:Java MathObservable类的具体用法?Java MathObservable怎么用?Java MathObservable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MathObservable类属于rx.observables包,在下文中一共展示了MathObservable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: runCode

import rx.observables.MathObservable; //导入依赖的package包/类
public void runCode() {
        //compile 'io.reactivex:rxjava-math:1.0.0'

//        http://blog.csdn.net/nicolelili1/article/details/52180643


        MathObservable.averageInteger(Observable.just(1, 2, 3, 4))
                .subscribe(new Subscriber<Integer>() {
                    @Override
                    public void onCompleted() {
                        println("onCompleted.");
                    }

                    @Override
                    public void onError(Throwable e) {
                        println("onError: " + e.getMessage());
                    }

                    @Override
                    public void onNext(Integer integer) {
                        println("onNext: " + integer);
                    }
                });


    }
 
开发者ID:Aiushtha,项目名称:Go-RxJava,代码行数:27,代码来源:Fragment_Average.java


示例2: runCode

import rx.observables.MathObservable; //导入依赖的package包/类
public void runCode() {

        MathObservable.sumInteger(Observable.just(11, 2, 3, 4, 5))
                .subscribe(new Subscriber<Integer>() {
                    @Override
                    public void onNext(Integer v) {
                        println( "onNext:." + v);

                    }

                    @Override
                    public void onCompleted() {
                        println("onCompleted:");
                    }

                    @Override
                    public void onError(Throwable e) {
                        println("onError:");
                    }
                });



    }
 
开发者ID:Aiushtha,项目名称:Go-RxJava,代码行数:25,代码来源:Fragment_Sum.java


示例3: runCode

import rx.observables.MathObservable; //导入依赖的package包/类
public void runCode() {

        MathObservable.max(Observable.just(0, 1, 2, 4))
                .subscribe(new Subscriber<Integer>() {
                    @Override
                    public void onCompleted() {
                        println("onCompleted");
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(Integer integer) {
                        println("onNext:"+integer);
                    }
                });


    }
 
开发者ID:Aiushtha,项目名称:Go-RxJava,代码行数:23,代码来源:Fragment_Max.java


示例4: runCode

import rx.observables.MathObservable; //导入依赖的package包/类
public void runCode() {

        MathObservable.min(Observable.just(0, 1, 2, 4))
                .subscribe(new Subscriber<Integer>() {
                    @Override
                    public void onCompleted() {
                        println("onCompleted");
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(Integer integer) {
                        println("onNext:"+integer);
                    }
                });


    }
 
开发者ID:Aiushtha,项目名称:Go-RxJava,代码行数:23,代码来源:Fragment_Min.java


示例5: doExecute

import rx.observables.MathObservable; //导入依赖的package包/类
public ExecutionResult doExecute(ExecutionContext executionContext, GraphQLObjectType parentType, Object source, Map<String, List<Field>> fields) {

        List<Observable<Pair<String, Object>>> observablesResult = new ArrayList<>();
        List<Observable<Double>> observablesComplexity = new ArrayList<>();
        for (String fieldName : fields.keySet()) {
            final List<Field> fieldList = fields.get(fieldName);

            ExecutionResult executionResult = resolveField(executionContext, parentType, source, fieldList);
            observablesResult.add(unwrapExecutionResult(fieldName, executionResult));
            observablesComplexity.add(calculateFieldComplexity(executionContext, parentType, fieldList,
                    executionResult != null ? ((GraphQLRxExecutionResult) executionResult).getComplexityObservable() : Observable.just(0.0)));
        }

        Observable<Map<String, Object>> result =
                Observable.merge(observablesResult)
                        .toMap(Pair::getLeft, Pair::getRight);

        GraphQLRxExecutionResult graphQLRxExecutionResult = new GraphQLRxExecutionResult(result, Observable.just(executionContext.getErrors()), MathObservable.sumDouble(Observable.merge(observablesComplexity)));
        return graphQLRxExecutionResult;
    }
 
开发者ID:oembedler,项目名称:spring-graphql-common,代码行数:21,代码来源:GraphQLDefaultRxExecutionStrategy.java


示例6: testJdbcObservableCountLettersInAllNames

import rx.observables.MathObservable; //导入依赖的package包/类
@Test
public void testJdbcObservableCountLettersInAllNames() {
    int count = MathObservable
            .sumInteger(db()
                    // select
                    .select("select name from person where name >?")
                    // set name
                    .parameter("ALEX")
                    // count letters
                    .get(COUNT_LETTERS_IN_NAME))
            // first result
            .first()
            // block and get result
            .toBlocking().single();
    assertEquals(19, count);
}
 
开发者ID:davidmoten,项目名称:rxjava-jdbc,代码行数:17,代码来源:DatabaseTestBase.java


示例7: testConvertObservableToInt

import rx.observables.MathObservable; //导入依赖的package包/类
@Test
public void testConvertObservableToInt() {
  Integer sum = MathObservable.sumInteger(Observable.just(1, 2, 8, 9, 10, 11)).toBlocking().first();
  System.out.println(sum);

  List<String> list = Observable.just("it", "was", "the", "best", "of", "times").buffer(100).toBlocking().single();
  System.out.println(list);
}
 
开发者ID:vgrazi,项目名称:rxjava-snippets,代码行数:9,代码来源:GeneralCodeSamples.java


示例8: testMax

import rx.observables.MathObservable; //导入依赖的package包/类
@Test
public void testMax() {
  Integer[] list = new Integer[]{10, 20, null, 30, 40, 50};
  Observable<Integer> observable = Observable.from(list);
  Observable<Integer> buffer = MathObservable.from(observable)
    .max(Integer::compareTo);
  buffer.subscribe(System.out::println,
    Throwable::printStackTrace,
    () -> System.out.println("Complete"));
}
 
开发者ID:vgrazi,项目名称:rxjava-snippets,代码行数:11,代码来源:GeneralCodeSamples.java


示例9: testSum

import rx.observables.MathObservable; //导入依赖的package包/类
@Test
public void testSum() {
  Integer[] list = new Integer[]{10, 20, null, 30, 40, 50};
  Observable<Integer> observable = Observable.from(list)
    .filter(s -> s != null);
  Observable<Integer> buffer = MathObservable.from(observable)
    .sumInteger(s -> s * 10);

  buffer.subscribe(System.out::println,
    Throwable::printStackTrace,
    () -> System.out.println("Complete"));
}
 
开发者ID:vgrazi,项目名称:rxjava-snippets,代码行数:13,代码来源:GeneralCodeSamples.java


示例10: testMath

import rx.observables.MathObservable; //导入依赖的package包/类
@Test
public void testMath() {
  Integer[] list = new Integer[]{10, 60, null, 65, 70, 80};
  Observable<Integer> observable = Observable.from(list)
    .filter(s -> s != null);

  Observable<Double> sum = MathObservable.from(observable)
    .sumDouble(s -> s * 1d);

  Observable<Double> max = MathObservable.from(observable)
    .max(Integer::compareTo)
    .map(s -> s * 1.);

  Observable<Double> min = MathObservable.from(observable)
    .min(Integer::compareTo)
    .map(s -> s * 1.);

  Observable<Double> medianStream = max.mergeWith(min);

  Observable<Double> midrange = MathObservable.from(medianStream).averageDouble(s -> s);
  midrange.subscribe((x) -> System.out.println("Mid range:" + x));

  Observable<Integer> midrangeInt = MathObservable.from(medianStream).averageInteger(Double::intValue);
  midrangeInt.subscribe((x) -> System.out.println("Mid range int:" + x));

  sum.subscribe((x) -> System.out.println("Sum:" + x),
    Throwable::printStackTrace,
    () -> System.out.println("Complete"));
}
 
开发者ID:vgrazi,项目名称:rxjava-snippets,代码行数:30,代码来源:GeneralCodeSamples.java


示例11: testMidRange

import rx.observables.MathObservable; //导入依赖的package包/类
@Test
  public void testMidRange() {
    Integer[] list = {10, 80, 90, 100};
    Observable<Integer> ints = Observable.from(list);
    Observable<Integer> min = MathObservable.from(ints).min(Integer::compareTo);
    Observable<Integer> max = MathObservable.from(ints).max(Integer::compareTo);
//    min.zipWith(max, (a, b) -> (b + a) / 2).subscribe(System.out::println);
    Observable.zip(min, max, (a, b) -> (b + a) / 2).subscribe(System.out::println);
  }
 
开发者ID:vgrazi,项目名称:rxjava-snippets,代码行数:10,代码来源:GeneralCodeSamples.java


示例12: completeValueForList

import rx.observables.MathObservable; //导入依赖的package包/类
@Override
protected ExecutionResult completeValueForList(ExecutionContext executionContext, GraphQLList fieldType, List<Field> fields, List<Object> result) {
    Observable<List<ListTuple>> cachedObservable =
            Observable.from(
                    IntStream.range(0, result.size())
                            .mapToObj(idx -> new ListTuple(idx, result.get(idx), null))
                            .toArray(ListTuple[]::new)
            )
                    .flatMap(tuple -> {
                        ExecutionResult executionResult = completeValue(executionContext, fieldType.getWrappedType(), fields, tuple.result);
                        if (executionResult instanceof GraphQLRxExecutionResult) {
                            return Observable.zip(Observable.just(tuple.index),
                                    ((GraphQLRxExecutionResult) executionResult).getDataObservable(),
                                    ((GraphQLRxExecutionResult) executionResult).getComplexityObservable(),
                                    ListTuple::new);
                        }
                        return Observable.just(new ListTuple(tuple.index, executionResult.getData(), Observable.just(1.0)));
                    })
                    .toList()
                    .cache();

    Observable<?> resultObservable = cachedObservable
            .map(listTuples -> {
                return listTuples.stream()
                        .sorted(Comparator.comparingInt(x -> x.index))
                        .map(x -> x.result)
                        .collect(Collectors.toList());
            });

    Observable<?> complexityObservable = cachedObservable
            .map(listTuples -> {
                return listTuples.stream()
                        .sorted(Comparator.comparingInt(x -> x.index))
                        .map(x -> x.complexity)
                        .collect(Collectors.toList());
            })
            .flatMap(combined -> Observable.from(combined));

    return new GraphQLRxExecutionResult(resultObservable, null, MathObservable.sumDouble((Observable<Double>) complexityObservable));
}
 
开发者ID:oembedler,项目名称:spring-graphql-common,代码行数:41,代码来源:GraphQLAbstractRxExecutionStrategy.java


示例13: getApplicationSize

import rx.observables.MathObservable; //导入依赖的package包/类
@Override
public long getApplicationSize(ApplicationScope applicationScope) {
    final IndexLocationStrategy indexLocationStrategy = indexLocationStrategyFactory.getIndexLocationStrategy(applicationScope);
    EntityIndex entityIndex = entityIndexFactory.createEntityIndex(indexLocationStrategy);
    GraphManager graphManager = graphManagerFactory.createEdgeManager(applicationScope);
    Long sum = ObservableTimer.time(
        MathObservable.sumLong(
            graphManager.getEdgeTypesFromSource(new SimpleSearchEdgeType(applicationScope.getApplication(), CpNamingUtils.EDGE_COLL_PREFIX, Optional.<String>absent()))
                .map(type -> CpNamingUtils.createCollectionSearchEdge(applicationScope.getApplication(), type))
                .map(edge -> entityIndex.getTotalEntitySizeInBytes(edge))
        ), sumTimer).toBlocking().last();

    return sum.longValue();
}
 
开发者ID:apache,项目名称:usergrid,代码行数:15,代码来源:AggregationServiceImpl.java


示例14: call

import rx.observables.MathObservable; //导入依赖的package包/类
@Override
public Observable<Integer> call(Observable<Integer> source) {
    return MathObservable.sumInteger(source);
}
 
开发者ID:davidmoten,项目名称:rxjava-jdbc,代码行数:5,代码来源:DatabaseTestBase.java


示例15: receive

import rx.observables.MathObservable; //导入依赖的package包/类
public Observable<Integer> receive( final ApplicationScope scope, final MarkedEdge edge,
                                    final UUID eventTimestamp ) {

    final long maxTimestamp = edge.getTimestamp();




    return edgeDeleteRepair.repair( scope, edge, eventTimestamp )
                           .flatMap( markedEdge -> {

                               Observable<Integer> sourceDelete = edgeMetaRepair
                                       .repairSources( scope, edge.getSourceNode(), edge.getType(), maxTimestamp );

                               Observable<Integer> targetDelete = edgeMetaRepair
                                       .repairTargets( scope, edge.getTargetNode(), edge.getType(), maxTimestamp );

                               return MathObservable.sumInteger( Observable.merge( sourceDelete, targetDelete ) );
                           } );
}
 
开发者ID:apache,项目名称:usergrid,代码行数:21,代码来源:EdgeDeleteListenerImpl.java



注:本文中的rx.observables.MathObservable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Vectors类代码示例发布时间:2022-05-22
下一篇:
Java GetContainersRequestPBImpl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap