io.reactivex.internal.functions.Functions.createArrayList()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中io.reactivex.internal.functions.Functions.createArrayList()方法的一些代码示例,展示了Functions.createArrayList()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Functions.createArrayList()方法的具体详情如下:
包路径:io.reactivex.internal.functions.Functions
类名称:Functions
方法名:createArrayList

Functions.createArrayList介绍

暂无

代码示例

代码示例来源:origin: ReactiveX/RxJava

@SuppressWarnings({ "unchecked", "rawtypes" })
public ObservableToListSingle(ObservableSource<T> source, final int defaultCapacityHint) {
  this.source = source;
  this.collectionSupplier = (Callable)Functions.createArrayList(defaultCapacityHint);
}

代码示例来源:origin: ReactiveX/RxJava

@SuppressWarnings({ "unchecked", "rawtypes" })
public ObservableToList(ObservableSource<T> source, final int defaultCapacityHint) {
  super(source);
  this.collectionSupplier = (Callable)Functions.createArrayList(defaultCapacityHint);
}

代码示例来源:origin: redisson/redisson

@SuppressWarnings({ "unchecked", "rawtypes" })
public ObservableToList(ObservableSource<T> source, final int defaultCapacityHint) {
  super(source);
  this.collectionSupplier = (Callable)Functions.createArrayList(defaultCapacityHint);
}

代码示例来源:origin: redisson/redisson

@SuppressWarnings({ "unchecked", "rawtypes" })
public ObservableToListSingle(ObservableSource<T> source, final int defaultCapacityHint) {
  this.source = source;
  this.collectionSupplier = (Callable)Functions.createArrayList(defaultCapacityHint);
}

代码示例来源:origin: ReactiveX/RxJava

public final <B> Observable<List<T>> buffer(ObservableSource<B> boundary, final int initialCapacity) {
  ObjectHelper.verifyPositive(initialCapacity, "initialCapacity");
  return buffer(boundary, Functions.<T>createArrayList(initialCapacity));

代码示例来源:origin: ReactiveX/RxJava

@SuppressWarnings("unchecked")
@Test
public void restartTimer() {
  Observable.range(1, 5)
  .buffer(1, TimeUnit.DAYS, Schedulers.single(), 2, Functions.<Integer>createArrayList(16), true)
  .test()
  .assertResult(Arrays.asList(1, 2), Arrays.asList(3, 4), Arrays.asList(5));
}

代码示例来源:origin: ReactiveX/RxJava

@Override
public Publisher<List<Integer>> createPublisher(final long elements) {
  return
      Flowable.range(1, 1000).collect(Functions.<Integer>createArrayList(128), new BiConsumer<List<Integer>, Integer>() {
        @Override
        public void accept(List<Integer> a, Integer b) throws Exception {
          a.add(b);
        }
      }).toFlowable()
    ;
}

代码示例来源:origin: ReactiveX/RxJava

@SuppressWarnings("unchecked")
@Test
public void restartTimer() {
  Flowable.range(1, 5)
  .buffer(1, TimeUnit.DAYS, Schedulers.single(), 2, Functions.<Integer>createArrayList(16), true)
  .test()
  .assertResult(Arrays.asList(1, 2), Arrays.asList(3, 4), Arrays.asList(5));
}

代码示例来源:origin: ReactiveX/RxJava

public final <B> Flowable<List<T>> buffer(Publisher<B> boundaryIndicator, final int initialCapacity) {
  ObjectHelper.verifyPositive(initialCapacity, "initialCapacity");
  return buffer(boundaryIndicator, Functions.<T>createArrayList(initialCapacity));

代码示例来源:origin: redisson/redisson

public final <B> Observable<List<T>> buffer(ObservableSource<B> boundary, final int initialCapacity) {
  ObjectHelper.verifyPositive(initialCapacity, "initialCapacity");
  return buffer(boundary, Functions.<T>createArrayList(initialCapacity));

代码示例来源:origin: ReactiveX/RxJava

public final Single<List<T>> toList(final int capacityHint) {
  ObjectHelper.verifyPositive(capacityHint, "capacityHint");
  return RxJavaPlugins.onAssembly(new FlowableToListSingle<T, List<T>>(this, Functions.<T>createArrayList(capacityHint)));

代码示例来源:origin: redisson/redisson

public final <B> Flowable<List<T>> buffer(Publisher<B> boundaryIndicator, final int initialCapacity) {
  ObjectHelper.verifyPositive(initialCapacity, "initialCapacity");
  return buffer(boundaryIndicator, Functions.<T>createArrayList(initialCapacity));

代码示例来源:origin: ReactiveX/RxJava

/**
 * Sorts the 'rails' of this ParallelFlowable and returns a Publisher that sequentially
 * picks the smallest next value from the rails.
 * <p>
 * This operator requires a finite source ParallelFlowable.
 *
 * @param comparator the comparator to use
 * @param capacityHint the expected number of total elements
 * @return the new Flowable instance
 */
@CheckReturnValue
@NonNull
public final Flowable<T> sorted(@NonNull Comparator<? super T> comparator, int capacityHint) {
  ObjectHelper.requireNonNull(comparator, "comparator is null");
  ObjectHelper.verifyPositive(capacityHint, "capacityHint");
  int ch = capacityHint / parallelism() + 1;
  ParallelFlowable<List<T>> railReduced = reduce(Functions.<T>createArrayList(ch), ListAddBiConsumer.<T>instance());
  ParallelFlowable<List<T>> railSorted = railReduced.map(new SorterFunction<T>(comparator));
  return RxJavaPlugins.onAssembly(new ParallelSortedJoin<T>(railSorted, comparator));
}

代码示例来源:origin: ReactiveX/RxJava

/**
 * Sorts the 'rails' according to the comparator and returns a full sorted list as a Publisher.
 * <p>
 * This operator requires a finite source ParallelFlowable.
 *
 * @param comparator the comparator to compare elements
 * @param capacityHint the expected number of total elements
 * @return the new Flowable instance
 */
@CheckReturnValue
@NonNull
public final Flowable<List<T>> toSortedList(@NonNull Comparator<? super T> comparator, int capacityHint) {
  ObjectHelper.requireNonNull(comparator, "comparator is null");
  ObjectHelper.verifyPositive(capacityHint, "capacityHint");
  int ch = capacityHint / parallelism() + 1;
  ParallelFlowable<List<T>> railReduced = reduce(Functions.<T>createArrayList(ch), ListAddBiConsumer.<T>instance());
  ParallelFlowable<List<T>> railSorted = railReduced.map(new SorterFunction<T>(comparator));
  Flowable<List<T>> merged = railSorted.reduce(new MergerBiFunction<T>(comparator));
  return RxJavaPlugins.onAssembly(merged);
}

代码示例来源:origin: ReactiveX/RxJava

@SuppressWarnings("unchecked")
@Test
public void bufferTimedExactBoundedError() {
  TestScheduler scheduler = new TestScheduler();
  PublishProcessor<Integer> pp = PublishProcessor.create();
  TestSubscriber<List<Integer>> ts = pp
  .buffer(1, TimeUnit.MILLISECONDS, scheduler, 1, Functions.<Integer>createArrayList(16), true)
  .test();
  pp.onError(new TestException());
  ts
  .assertFailure(TestException.class);
}

代码示例来源:origin: ReactiveX/RxJava

@SuppressWarnings("unchecked")
@Test
public void bufferTimedExactBoundedError() {
  TestScheduler scheduler = new TestScheduler();
  PublishSubject<Integer> ps = PublishSubject.create();
  TestObserver<List<Integer>> to = ps
  .buffer(1, TimeUnit.MILLISECONDS, scheduler, 1, Functions.<Integer>createArrayList(16), true)
  .test();
  ps.onError(new TestException());
  to
  .assertFailure(TestException.class);
}

代码示例来源:origin: redisson/redisson

/**
 * Sorts the 'rails' of this ParallelFlowable and returns a Publisher that sequentially
 * picks the smallest next value from the rails.
 * <p>
 * This operator requires a finite source ParallelFlowable.
 *
 * @param comparator the comparator to use
 * @param capacityHint the expected number of total elements
 * @return the new Flowable instance
 */
@CheckReturnValue
@NonNull
public final Flowable<T> sorted(@NonNull Comparator<? super T> comparator, int capacityHint) {
  ObjectHelper.requireNonNull(comparator, "comparator is null");
  ObjectHelper.verifyPositive(capacityHint, "capacityHint");
  int ch = capacityHint / parallelism() + 1;
  ParallelFlowable<List<T>> railReduced = reduce(Functions.<T>createArrayList(ch), ListAddBiConsumer.<T>instance());
  ParallelFlowable<List<T>> railSorted = railReduced.map(new SorterFunction<T>(comparator));
  return RxJavaPlugins.onAssembly(new ParallelSortedJoin<T>(railSorted, comparator));
}

代码示例来源:origin: redisson/redisson

/**
 * Sorts the 'rails' according to the comparator and returns a full sorted list as a Publisher.
 * <p>
 * This operator requires a finite source ParallelFlowable.
 *
 * @param comparator the comparator to compare elements
 * @param capacityHint the expected number of total elements
 * @return the new Flowable instance
 */
@CheckReturnValue
@NonNull
public final Flowable<List<T>> toSortedList(@NonNull Comparator<? super T> comparator, int capacityHint) {
  ObjectHelper.requireNonNull(comparator, "comparator is null");
  ObjectHelper.verifyPositive(capacityHint, "capacityHint");
  int ch = capacityHint / parallelism() + 1;
  ParallelFlowable<List<T>> railReduced = reduce(Functions.<T>createArrayList(ch), ListAddBiConsumer.<T>instance());
  ParallelFlowable<List<T>> railSorted = railReduced.map(new SorterFunction<T>(comparator));
  Flowable<List<T>> merged = railSorted.reduce(new MergerBiFunction<T>(comparator));
  return RxJavaPlugins.onAssembly(merged);
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void dispose() {
  TestHelper.checkDisposed(Flowable.range(1, 5).buffer(1, TimeUnit.DAYS, Schedulers.single()));
  TestHelper.checkDisposed(Flowable.range(1, 5).buffer(2, 1, TimeUnit.DAYS, Schedulers.single()));
  TestHelper.checkDisposed(Flowable.range(1, 5).buffer(1, 2, TimeUnit.DAYS, Schedulers.single()));
  TestHelper.checkDisposed(Flowable.range(1, 5)
      .buffer(1, TimeUnit.DAYS, Schedulers.single(), 2, Functions.<Integer>createArrayList(16), true));
  TestHelper.checkDisposed(Flowable.range(1, 5).buffer(1));
  TestHelper.checkDisposed(Flowable.range(1, 5).buffer(2, 1));
  TestHelper.checkDisposed(Flowable.range(1, 5).buffer(1, 2));
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void dispose() {
  TestHelper.checkDisposed(Observable.range(1, 5).buffer(1, TimeUnit.DAYS, Schedulers.single()));
  TestHelper.checkDisposed(Observable.range(1, 5).buffer(2, 1, TimeUnit.DAYS, Schedulers.single()));
  TestHelper.checkDisposed(Observable.range(1, 5).buffer(1, 2, TimeUnit.DAYS, Schedulers.single()));
  TestHelper.checkDisposed(Observable.range(1, 5)
      .buffer(1, TimeUnit.DAYS, Schedulers.single(), 2, Functions.<Integer>createArrayList(16), true));
  TestHelper.checkDisposed(Observable.range(1, 5).buffer(1));
  TestHelper.checkDisposed(Observable.range(1, 5).buffer(2, 1));
  TestHelper.checkDisposed(Observable.range(1, 5).buffer(1, 2));
  TestHelper.checkDisposed(PublishSubject.create().buffer(Observable.never()));
  TestHelper.checkDisposed(PublishSubject.create().buffer(Functions.justCallable(Observable.never())));
  TestHelper.checkDisposed(PublishSubject.create().buffer(Observable.never(), Functions.justFunction(Observable.never())));
}

相关文章