withItem

fun <T> ArrayList<T>.withItem(item: T): ArrayList<T>

Gets a clone of an ArrayList with an additional item

Solves concurrent modification problems - everyone who had a reference to the previous arrayList can keep using it because it hasn't changed

fun <T> HashSet<T>.withItem(item: T): HashSet<T>

Gets a clone of a HashSet with an additional item

Solves concurrent modification problems - everyone who had a reference to the previous hashSet can keep using it because it hasn't changed