reactor-kotlin-extensions / reactor.kotlin.extra.math / reactor.core.publisher.Flux

Extensions for reactor.core.publisher.Flux

average

Extension to compute the Double average of all values emitted by a Flux of Number and return it as a Mono of Double.

fun <T : Number> Flux<T>.average(): Mono<Double>

Extension to map arbitrary values in a Flux to Numbers and return the average of these Numbers as a Mono of Double.

fun <T> Flux<T>.average(mapper: (T) -> Number): Mono<Double>

max

Extension to find the highest value in a Flux of Comparable values and return it as a Mono of T.

fun <T : Comparable<T>> Flux<T>.max(): Mono<T>

Extension to find the highest value in a Flux and return it as a Mono. The highest value is defined by comparisons made using a provided Comparator.

fun <T> Flux<T>.max(comp: Comparator<T>): Mono<T>

Extension to find the highest value in a Flux and return it as a Mono. The highest value is defined by comparisons made using a provided function that behaves like a Comparator.

fun <T> Flux<T>.max(comp: (T, T) -> Int): Mono<T>

min

Extension to find the lowest value in a Flux of Comparable values and return it as a Mono of T.

fun <T : Comparable<T>> Flux<T>.min(): Mono<T>

Extension to find the lowest value in a Flux and return it as a Mono. The lowest value is defined by comparisons made using a provided Comparator.

fun <T> Flux<T>.min(comp: Comparator<T>): Mono<T>

Extension to find the lowest value in a Flux and return it as a Mono. The lowest value is defined by comparisons made using a provided function that behaves like a Comparator.

fun <T> Flux<T>.min(comp: (T, T) -> Int): Mono<T>

sum

Extension to compute the Long sum of all values emitted by a Flux of Number and return it as a Mono of Long.

fun <T : Number> Flux<T>.sum(): Mono<Long>

Extension to map arbitrary values in a Flux to Numbers and return the sum of these Numbers as a Mono of Long.

fun <T> Flux<T>.sum(mapper: (T) -> Number): Mono<Long>

sumDouble

Extension to compute the Double sum of all values emitted by a Flux of Number and return it as a Mono of Double.

fun <T : Number> Flux<T>.sumDouble(): Mono<Double>

Extension to map arbitrary values in a Flux to Numbers and return the sum of these Numbers as a Mono of Double, thus avoiding rounding down to zero decimal places.

fun <T> Flux<T>.sumDouble(mapper: (T) -> Number): Mono<Double>