On Dec 10, 9:18 pm, red floyd <no.s...@here.dude> wrote:
[...]
> Anyways, sip_address, I'd define a class of timer objects, and
> then use a std:
riority_queue() to maintain them. Note that
> if you need to delete an element mid-queue (kill a timer
> before it's time), then you should derive from
> std:
riority_queue -- PRIVATELY -- to gain access to the
> underlying (protected) container.
What's wrong with using std::set or std::multi_set, sorted by
time, and using std::set::iterator as the handle for the timer
queue entry (to be able to delete it). Alternatively, you could
simply use Timer* as the handle---when you wanted to delete,
std::supports erase by key, so deleting *handle will do the
trick. (In this case, you'd probably want to use std::set, with
each timer element having a unique identifier, which would serve
as a secondary key, to ensure that erase only affects a single
element. Any other arrangement which allows uniquely
indentifying the entries can be made work, however.)
--
James Kanze (GABI Software) email:
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34