Skip to content

Instantly share code, notes, and snippets.

@nbness2
Created May 20, 2023 10:50
Show Gist options
  • Save nbness2/b532f491bacd2cff7abf08070ea1d0b3 to your computer and use it in GitHub Desktop.
Save nbness2/b532f491bacd2cff7abf08070ea1d0b3 to your computer and use it in GitHub Desktop.
fun <I: Item> ItemContainer<I>.dementhiumShift(predicate: (I) -> Boolean = Item::isInvalidItem) {
val oldData: List<I> = items.toList()
items.clear()
var ptr = 0
items.forEachIndexed { itemIndex, item ->
if (predicate(item)) {
set(ptr++, oldData[itemIndex])
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment