This way my set is sorted by the timestamp, but now I want to check if a particular ID is in my set and find it.
Is this possible?
I have solved it using two different maps, one sorted by the ID and the other by the timestamp. Therefore, I have to insert in both maps, which is not a good solution from the point of view of performance.
If you don't, then just write another function object and pass it to
std::find_if() instead of my lambda expression. (Either approach
is O(n) lookup)
However, if you find that you need to sort by timestamp and look up
by ID, and you have the boost libraries available, consider using a
boost::multi_index_container instead.
I'm afraid I can't use boost libraries. In any case, I trying to get a good lookup time but I don't know if using find_if will help me. Find() provides logarithmic time lookups, but if I use find_if(), the lookup time will be the same as iterating the data structure, am i right?
I will try to do my own function and see if it works :)