English | 简体中文

api-docs / org.ktorm.entity / foldTo

foldTo

inline fun <E : Any, K : Any, R, M : MutableMap<in K?, R>> EntityGrouping<E, *, K>.foldTo(
    destination: M,
    initialValueSelector: (key: K?, element: E) -> R,
    operation: (key: K?, accumulator: R, element: E) -> R
): M
(source code)

Groups elements from the source sequence by key and applies operation to the elements of each group sequentially,
passing the previously accumulated value and the current element as arguments, and stores the results in the given
destination map. An initial value of accumulator is provided by initialValueSelector function.

This function is delegated to Grouping.foldTo, more details can be found in its documentation.

inline fun <E : Any, K : Any, R, M : MutableMap<in K?, R>> EntityGrouping<E, *, K>.foldTo(
    destination: M,
    initialValue: R,
    operation: (accumulator: R, element: E) -> R
): M
(source code)

Groups elements from the source sequence by key and applies operation to the elements of each group sequentially,
passing the previously accumulated value and the current element as arguments, and stores the results in the given
destination map. An initial value of accumulator is the same initialValue for each group.

This function is delegated to Grouping.foldTo, more details can be found in its documentation.