I'm asking what the best idea is to update a set of data after a certain time.
I have an Array of Objects, each with its own timestamp and other variables. In, for example, 5 minutes a variable of one of the objects has to automatically be changed, and for another item it could be in 8 minutes, etc.
My current solution is to have a timer that runs a function every 15 seconds to compare the timestamp of every Object in the Array to the current timestamp, but this can't be efficient especially as the Array grows in size.
I don't care about the programming specifics, but what would be the abstract idea of how to implement this?
Use a priority queue. Each item's priority is the clock time at which its next update is due. It's O(log(N)) time to remove the next item from the queue and O(log(N)) time to reinsert the item with its next due time.