PaulS:
I'd suggest that some of your names are misleading:
I agree. I'll have to work on that.
Your class should have a constructor that also calls init(), so that you can be assured that init() gets called.
Of course (he says after doing a bit of reading I should have done before on the library page). Thanks!
You deleteEvent() method always removes the last event. I don't like that design. It should be able to remove the nth event.
Actually it's the first event that gets removed (indx=0), but I get your point.
Your checkEvents() method returns true if any event occurred. It should return -1 for no event, and n for the nth event.
Actually it only returns true if the first event has occurred.
Your other methods assume that the first event in the list is the event that fired.
Well, the implementation may be a bit naive, but the list is maintained in ascending chronological order so it will always be the first event that fired.
The idea was to make it inexpensive to check to see if an event has expired (you'll do that many times per second) and moving the "cost" to the add since you'll be doing that less often.
I do see a danger of too deep a list and some of the end events never being serviced but I think that won't typically be an issue given the limits on event time (1/10 second) and the fact that there isn't much need to have more than a few events firing more than once per second.
Really, I think your problem is in the Events class. You need to know which event occurred, so that you can get the data for that event. Deleting the event, and re-adding it, is silly. Just add a method to reset the nth event's eventTime value.
In retrospect, I agree about deleting and re-adding it. No need to physically maintain chronological order when I could simply use a pointer in each structure and maintain that in the proper order. One thought behind delete and re-adding was that perhaps the new event being added would be different than the previous event (or not even needed).
I should modify deleteEvent to re-order the event back into the list when the event fires (and possibly re-name the method since it isn't deleting anymore).
Thanks for the help,
Brad (KF7FER)
EDIT: Was a stupid idea to do the re-schedule in checkEvent since I have to pull the data first