I have a function that is to be called if a list has changed since it was last called, what would be the best way of implementing this?
ex:
List<A> OurList = new List<A>();
private void Update()
{
Boolean Changed = //?
if(Changed) CheckList(OurList);
}
I would have assumed make a variable to store the old list and compare, but how would I update the old list to the new list without copying it all out? (If I do an assign, it will update the “old list” too)
The most efficient way would be to wrap the
List<>in your own class and have all the mutating methods (Add, Remove) set a boolean flag.Your Method can then just look at that flag and reset it.