Skip to content

Instantly share code, notes, and snippets.

@nbness2
Created May 20, 2023 10:54
Show Gist options
  • Save nbness2/adb52dd7705b5146c7401156caf72b5d to your computer and use it in GitHub Desktop.
Save nbness2/adb52dd7705b5146c7401156caf72b5d to your computer and use it in GitHub Desktop.
fun <I: Item> ItemContainer<I>.codeusaShift(predicate: (I) -> Boolean = Item::isInvalidItem) {
val tempBank = items
var id = 0
tempBank.forEachIndexed { index, item ->
if (!predicate(item)) {
items[id] = tempBank[id++]
}
}
for (index in id until items.size) {
items[index] = InvalidItem
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment