Last active
May 22, 2023 07:47
-
-
Save hikaru-im/4f42c4d20d975e077853d0859e976c40 to your computer and use it in GitHub Desktop.
ExposedDropdownMenuBox for Compose Mutiplatform
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package androidx.compose.ui.util | |
import kotlin.contracts.ExperimentalContracts | |
import kotlin.contracts.contract | |
@OptIn(ExperimentalContracts::class) | |
fun <T> List<T>.fastAll(predicate: (T) -> Boolean): Boolean { | |
contract { callsInPlace(predicate) } | |
fastForEach { if (!predicate(it)) return false } | |
return true | |
} | |
@OptIn(ExperimentalContracts::class) | |
inline fun <T> List<T>.fastForEach(action: (T) -> Unit) { | |
contract { callsInPlace(action) } | |
for (index in indices) { | |
val item = get(index) | |
action(item) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reference to fastAll:
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/ui/ui-util/src/commonMain/kotlin/androidx/compose/ui/util/ListUtils.kt