Add call tab event grouping.

This commit is contained in:
Alex Hart
2023-04-12 13:22:33 -03:00
committed by Greyson Parrelli
parent fd1ff5e438
commit e8570c3680
11 changed files with 164 additions and 69 deletions

View File

@@ -0,0 +1,8 @@
package org.signal.core.util
/**
* Flattens a List of Map<K, V> into a Map<K, V> using the + operator.
*
* @return A Map containing all of the K, V pairings of the maps contained in the original list.
*/
fun <K, V> List<Map<K, V>>.flatten(): Map<K, V> = foldRight(emptyMap()) { a, b -> a + b }

View File

@@ -137,6 +137,11 @@ inline fun <T> Cursor.readToList(predicate: (T) -> Boolean = { true }, mapper: (
return list
}
@JvmOverloads
inline fun <K, V> Cursor.readToMap(predicate: (Pair<K, V>) -> Boolean = { true }, mapper: (Cursor) -> Pair<K, V>): Map<K, V> {
return readToList(predicate, mapper).associate { it }
}
inline fun <T> Cursor.readToSet(predicate: (T) -> Boolean = { true }, mapper: (Cursor) -> T): Set<T> {
val set = mutableSetOf<T>()
use {