0

I have a std::map like so: std::map<UINT32,USER_DEFINED_X> with a variable number N of elements. This map is part of an overall application that runs on a real time framework. The map contains elements such that it includes times for when certain activities are supposed to occur. During each frame, the map is scanned to see if any of those times match up with current time. There is one condition that needs to be checked though before processing the activities. I need to check to see if the element that is going to be processed is the first one in the list that is being processed. I am not sure how to do that. One approach I thought about using was to create another temporary map/array where I would store the element that has been processed in order, then get the order from that temporary array/map?

Does anybody know of a better way I can conduct this operation?

CircAnalyzer
  • 610
  • 1
  • 9
  • 29
  • `check to see if the element that is going to be processed is the first one in the list that is being processed.` Maybe I'm slow, but I'm not following exactly what's meant to happen here. Is the map's key the time, btw? It sounds like a priority queue might help? – Millie Smith Sep 27 '18 at 04:51
  • what i meant to say was if I need to process a particular element from the map, I need to check to see if there were other elements that were already processed prior. that's the part I don't know how to do other than adding elements to another array, and if the other array has elements in it, then that means I have already dealt with the first one...no the key is not the time. the key is an ID of the data structure located in the value which contains the time. – CircAnalyzer Sep 27 '18 at 04:55
  • You could define a custom predicate that sorts the items in the map based on the time. Something like this: https://stackoverflow.com/questions/5733254/how-can-i-create-an-own-comparator-for-a-map Is this what you mean by "...is the first one in the list that is being processed... ", do you mean first in time order or do you mean something else? – Michael Sep 27 '18 at 04:58
  • Can an element finish being processed before another element that was started before it, or is it guaranteed that the order you start processing elements is the order in which you finish processing elements? – Geezer Sep 27 '18 at 05:40
  • Can you provide the definition of `USER_DEFINED_X`, and your attempted solution? What's the "list that is being processed"? – Caleth Sep 27 '18 at 08:27

0 Answers0