Link to home
Start Free TrialLog in
Avatar of Viviana1215
Viviana1215

asked on

how to pop the event which i want from STL list *URGENT*

I have a question for the STLlist.

Event::Event(){ uid_=UNKNOWN; event_time_=BEYOND; eh_=NULL; }
list<Event> elist;

If I push 3 events into the list, ids are 1,2,3, the eventtime are 1s,2s,3s. then I use elist.sort().  and elist.pop_front(), the event which pops out is id=1. During handle this event, i want to change the event time for id=3 to 1.5s. after i changed the value, and finished handling the event id=1, i use sort() again, and i think the event sequence should be 1,3,2 according to the eventtime, 1s, 1.5s,2s. But in fact it is still 1,2,3. So how can I make the sequence like 1,3,2? I tried use remove() to remove the event id=3, and write a push a new event, but still can not work. is there anybody can give me a hand to tell me how to write that codes? Thank you very much!~~^_________________^
            
Avatar of Axter
Axter
Flag of United States of America image

Can you please post your current code?
Avatar of Viviana1215
Viviana1215

ASKER

HI Axter
This is the link to my code.
http://www.cc.puv.fi/~e0200753/1/mine/1.cpp

my problem is in the destination() function. If the node is the destination, then it will change it's eventtime, and then when the currenttime==to eventtime, this event should be pop out.
My project is to simulate the CSMA/CA protocol. Before node going to send the package, it should wait for a DIFS time, and then random generate a number of slot times, which is backoff. after the difs, when the difs is finished, it goes to backoff status, before it going to wait a slot time, it should check the status of the channel, if it is busy, it changes to the receiver immediately, and wait a sendtime which is the time for sending a package. when the node finish the backoff, it starts to send the package, now all the node in the channel should be changed into receiver mode, and after the sendtime, eachnode will check if itself is the destination, if not, it will throw away the package, else it will wait a sifs time and send back the ACK. my problem is in here, when all the node change to the receiver, i need to change the eventtime to the currenttime+sendtime, and the sequence in the list should be changed as the eventtime. now, the sequence still the same after i sort.

Sorry that I can not express clearly the aim for this project, and thank you for all the help and I really appreciate it .
ASKER CERTIFIED SOLUTION
Avatar of B1-66ER
B1-66ER

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial