Note that there are some explanatory texts on larger screens.

plurals
  1. POLookup structure for handling future events (time based)
    primarykey
    data
    text
    <p>I am looking for an efficient data structure, that'll allow me to cue events ... that is, i will be having an app, where at any time in execution, it is possible, that an event will be raised for a future point in execution ... something like:</p> <ul> <li>t=20: in 420 seconds, A occurs</li> <li>t=25: in 13 seconds, B occurs</li> <li>t=27: in 735 seconds, C occurs</li> <li>...</li> </ul> <p>so i'd like to have a data structure, where i can put in any event in any time in the future and where i can get and (by doing so) remove all due events ... also, a plus would be, if i were able to remove an event from the datastructure (because it was canceled) ... not too important though, since i can simply flag it as cancelled ...</p> <p>my first thought was, maybe to do some sort of tree, but i guess the removing-due-events part requires a lot of rebalancing ...</p> <p>i am considering simply having an int hash, mapping timestamps to either null or stacks of events that are to occur at that point in time ... i think in scenarios, with a lot of events (possibly multiple every second - which is what i intend to work with), this actually isn't such a bad idea after all ...</p> <p>so i am eager to hear your input ... :)</p> <hr> <p><strong>edit:</strong></p> <ul> <li>to be more specific: i think n here is at about 100K-1M, and i guess i might be having about 1-100 events/second ...</li> <li>the t is of no special importance ... it is only to illustrate that a future event can be "enqueued" at any time ...</li> </ul> <hr> <p>thanks</p> <p>back2dos</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload