collect
fun <T, C> Observable<T>.collect(collectionSupplier: () -> C, accumulator: (C, T) -> Unit): Single<C>
Collects elements emitted by the finite source Observable into a mutable data structure C and returns a Single that emits this structure. The accumulator should mutate the structure adding elements into it.
Please refer to the corresponding RxJava document.