for an undo-redo system i need to call a function that does a deepcopy of a list everytime the list is changed in some way (add, remove, insert, modify element at an index).
I thought about making the list private and writing a method for each of the operations. However this adds a lot of bulky code. Also it is not very practical and looks not so nice for example list[i] = 10
becomes modify(list, i, 10)
. The modify method looks like this:
public void Modify(List<int> list, int index, int value) {
Logger.DeepCopy(list);
list[i] = value;
}
Is there a way to keep the methods of the list as they are?