Convert SenderKeyTable to kotlin.

This commit is contained in:
Greyson Parrelli
2022-12-07 14:31:32 -05:00
committed by Alex Hart
parent 98980b8192
commit c1cc2b064c
3 changed files with 142 additions and 147 deletions

View File

@@ -105,4 +105,16 @@ inline fun <T> Cursor.readToSet(predicate: (T) -> Boolean = { true }, mapper: (C
return set
}
inline fun <T> Cursor.firstOrNull(predicate: (T) -> Boolean = { true }, mapper: (Cursor) -> T): T? {
use {
while (moveToNext()) {
val record = mapper(this)
if (predicate(record)) {
return record
}
}
}
return null
}
fun Boolean.toInt(): Int = if (this) 1 else 0