commonMain.ovh.plrapps.mapcompose.utils.Collections.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mapcompose-mp-desktop Show documentation
Show all versions of mapcompose-mp-desktop Show documentation
A Compose Multiplatform library to display tiled maps, with support for markers, paths, and rotation
The newest version!
package ovh.plrapps.mapcompose.utils
fun MutableCollection.removeFirst(predicate: (T) -> Boolean): Boolean {
var removed = false
val it = iterator()
while (it.hasNext()) {
if (predicate(it.next())) {
it.remove()
removed = true
break
}
}
return removed
}
fun MutableList.swap(i1: Int, i2: Int): MutableList = apply {
val t = this[i1]
this[i1] = this[i2]
this[i2] = t
}