Skip to content

Instantly share code, notes, and snippets.

@yenerm
Last active October 8, 2020 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yenerm/078e50bf5bd361a9186d5a81aecd5f53 to your computer and use it in GitHub Desktop.
Save yenerm/078e50bf5bd361a9186d5a81aecd5f53 to your computer and use it in GitHub Desktop.
<!-- Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 -->
class ListWithTrash <T>(
private val innerList: MutableList<T> = ArrayList<T>()
) : MutableCollection<T> by innerList {
var deletedItem : T? = null
override fun remove(element: T): Boolean {
deletedItem = element
return innerList.remove(element)
}
fun recover(): T? {
return deletedItem
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment